Categories
java

Eclipse Hmm…

I have been using the heck out of Eclipse since my last “Eclipse Hmm…” post. I really like Eclipse. I’m starting to feel very productive with it. I like it so much that I don’t even long for the “good old days”, back when I used vi for all my Java development. That being said, I still have a ton of things that I need to learn/understand about Eclipse. Here are a couple things that are making me crazy today.

1. How do I find a class quick? Say that somebody says go look at ClassA. They don’t tell me what project or package the class is in. My problem is that I’m working with 5 projects. Each project has numerous packages. And then in total there are hundreds of classes. I’d love a way to use a “Google type search” through all my project/packages for a given class name….. What I currently do is drop out of Eclipse and run a Unix find command:

% find $workspace_home -name “*.java” -exec grep -l “ClassA” {} \; | less

That find covers me when I don’t know the full class name, but I sure would like a quick way to find the class without leaving Eclipse.

2. What is the story with all the possible options of setting up a “Java Build Path” for a project? First you have to decide if you want to “import” an actual Eclipse project, and if you don’t go that route you then have to move to the Libraries tab. From the Libraries tab I get lost with all the JAR options (“Add JARs…”, “Add External JARs…”, and “Add Library…”). Is there a best practice for this?

I guess I’m going to have to break down and buy an Eclipse book, or find a good Eclipse site to help clear this up.

5 replies on “Eclipse Hmm…”

What I do to avoid the whole lib/*.jar issue is use Maven. I don’t want to start a whole new Maven thread but with Maven’s conecept of an artifact (jar) repository this problem is solved. Coupled with the MevinIde Eclipse plugin it makes adding jars to Eclipse’s classpath an effort of three clicks.

Erik, the easiest way to find a given class is to click “Navigate->Open Type” and then type the name of the class you want to open. It realtime searches all defined types that are accessible from opened projects.

As far as managing the build path, I’m not too sure about the “Add Library” button because I’m not sure I understand the difference between a library and a jar. But “Add JAR” is mainly for adding jars that are relative to the current project, i.e. without fully qualified paths, while “Add External JAR” is for adding jars with fully qualified paths. And “Add Class Folder” is for adding a directory that contains precompiled classes.

Hey Scott….

I’ve heard that the whole “jar management” thing is where Maven shines. I’m working at a startup that is currently more concerned with getting a product out the door so I don’t have the time to stop development and work Maven into our system.

Once we get a beta release out I’ll take some time and look at Maven. I’m sure it does a lot more then just “do a good job with jars”. I’m juggling 20-25 jars and 5 eclipse projects (each with their own build.xml) that will all make up our project. I’m not sure how much work it takes to move the ant scripts into maven, but I’ll find out…..

Erik

Hey Josh…. Glad to see you’re still reading my garbage… 🙂

The “Navigate -> Open Type” was a great tip. I saw that it handles wildcard searches. It will be a staple of mine. There is so much “stuff” in Eclipse. I’ll be learning new tricks every day…

The Jar/Library thing is still a little hazy. I’m now cool with the Jar/External Jar option, but I need to find out what the difference is between a jar and a library. And I saw that the “Add Class Folder” is only for class files that are a part of Eclipse. I wonder if the “Add Library” is for class folders that aren’t in Eclipse projects.

I’ll do some digging…

Hi Erik.

Thanks to your site I was able to determine the difference between Add Jars and Add External Jars.

Libraries allow you (the developer) to constuct collections of Jars. These collections are given a meaningful name and can be used in any number of projects.

For example: if you have a number of projects that depend on XML functionality you may construct a user library which lists all the XML Jars you need. Then next time you need to “knock up” a similar project you merely add that library rather than go through the process of identifying each separate Jar.

Also imagine you find a third party Jar that meets your needs better than the one you have been using. With a library it is a simple matter of changing the particular Jar reference. Then all your projects that refer to that library now use the new Jar.

Hope this helps?

Leave a Reply

Your email address will not be published. Required fields are marked *