The Evils of Add External Jar
Chris Hogue's Blog |
January 19, 2007 10:01 AM
|
Comments (1)
There are a lot of good features and options Eclipse provides to you as a developer.
On the other hand, there are some that can lead you into trouble as well. One in
particular that shows up throughout the IDE is the Add External Jars option.
With few exceptions, most developers these days don't work alone; they work in
teams. Working in teams means using source code management systems and sharing code
with other people on other machines. (Actually, working alone should typically mean
using SCM as well, but that's a topic for another day).
What does this have to do with the Add External Jars option? The problem is that
Add External Jars puts an absolute path into the project metadata--the same metadata
that is used by all developers on different machines. Once you use this and end
up with absolute paths in your project settings, you check in those project files
and now everyone has to have the exact same paths on their system. And this is assuming
you're not using different platforms where paths are of different formats. Then
you're really out of luck.
The moral of the story is, don't use Add External Jars.
The alternatives are:
1. Use the Add JARs... option. This allows you to reference jars in the workspace,
but I only ever use this to reference jars in the same project--typically in a "lib"
directory set up in the root. These jars are usually checked into SCM along with
the project.
2. If you don't want to check jars in, consider using an Eclipse classpath variable
(Window > Preferences > Java > Build Path > Classpath Variables). The
downside to this option is that each developer has to set up this variable in their
IDE, but then by using the Add Variable... button the paths are relative to this
configurable location.
3. You could package them as J2EE Libraries and add them that way as well. I won't
go into detail about this option here, but will discuss it in a later post.
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Nice graphic Chris :-)
Posted by: jonmountjoy on January 19, 2007 at 11:46 AM
|