jlazevedo
jlazevedo

Reputation: 82

Set Eclipse Build Path Libraries from Project dir

I'm using eclipse with svn and when I add some .jar files to my Build Path eclipse add the jar with the full path from the root.

I know for sure that the file will always be in a folder called lib in the same directory as my project:

for example: ~/lib ~/proj

Can I add the file taking my project's directory as a reference? Something like ../lib?

Because, right now, when somebody makes an update the Build Path needs to be changed...

Thanks a lot

Upvotes: 1

Views: 2616

Answers (1)

A4L
A4L

Reputation: 17595

under

Window > Preferences > java > Build Path > User Libraries 

you can define user libraries, witch you can add to your class path. just say new type in a name (for example MY_EXTERNAL_LIB_FOO) and hit ok. Then select it (simple click) and hit add JAR..., you can then brows your jars and add the ones you want (multi select is possible)

the entry in .classpath will look something like this

<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/MY_EXTERNAL_LIB_FOO"/>

this way you can abstract the location for the libs for your projects, they only need to know the name, Eclipse needs to know where the Libs for a name are located.

If you are versioning the libs too within you project then when editing the Build path hit add JARs... and not add External JARs... you will be prompted wi a list of all the project in the actual workspace, choose the onse you have in your project. the entries in .classpath will be relative to your project.

So if you have the following project layout

+ MyProject
    + src
    + lib
       some_3rd_party_lib.jar

then the entry in .classpath will look like

<classpathentry kind="lib" path="lib/some_3rd_party_lib.jar"/>

Upvotes: 1

Related Questions