Issue
Here is my .classpath file, after I have added two more external jars (org.restlet.ext.simple.jar and org.simpleframework.jar):
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.jackson.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
<attributes>
<attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.ssl.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
<attributes>
<attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
<attributes>
<attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/api"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.jsslutils_1.0/org.jsslutils.jar"/>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.codehaus.jackson_1.4/org.codehaus.jackson.core.jar"/>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.codehaus.jackson_1.4/org.codehaus.jackson.mapper.jar"/>
<classpathentry kind="lib" path="../3rd_party/guice-3.0/aopalliance.jar"/>
<classpathentry kind="lib" path="../3rd_party/guice-3.0/guice-3.0.jar"/>
<classpathentry kind="lib" path="../3rd_party/guice-3.0/javax.inject.jar"/>
<classpathentry kind="lib" path="C:/dev/poc/3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.simple.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
<attributes>
<attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/dev/poc/3rd_party/restlet-jse-2.0.10/lib/org.simpleframework_4.1/org.simpleframework.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Notice that they have been added with absolute paths, unlike other entries which are with relative ones, but only because I manually edit this file each time new external jars are added.
My question is can I somehow tell Eclipse to use relative paths of newly added external jars?
Thanks.
Solution
One solution is to not use external jars, but to put your jars into a project, and then use Add Jar(s) instead of Add External Jar(s).
This makes sense from the point of view of source control, you can add/remove dependencies as you need them. It also means that when you update one jar for a separate project, it'll not affect this one.
We've done this in the past, we had a single project which contained all of the jars, which were referred to in the build paths of other projects.
But now we use maven, so we don't need to do that any more.
Answered By - Matthew Farwell
Answer Checked By - Willingham (JavaFixing Volunteer)