Reputation: 3807
The only way I know for adding additional libraries in a Java project (in Eclipse) is by manually adding them to the project's build path.
Is there a way in which I just create a folder, and anything inside it (.jars, to be more precise) is added to the classpath? Can I do something like that in eclipse?
Upvotes: 0
Views: 3727
Reputation: 12257
You have to care about the classpath but also about the build.properties. If it is not part of the build properties, the libraries will not be part of the generated *.jar file.
Let assume that your plugin is named 'rts.core.libs' and the project includes a folder named 'native/dll'.
Your file .classpath will look like
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="rts.core.libs/native/dll"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
and your build.properties file looks like
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
native/
Upvotes: 0
Reputation: 8946
First thing i will suggest is started using maven it handles the dependency problem very well
or
create a lib folder Put all the JARs into a lib folder inside of your project.
Now you can select all JARs in that folder, right click -> Build Path -> Add To Build Path.
Or just you can define a "User Library" which contains all the JARs and add that single item to your project's build path.
Upvotes: 0
Reputation: 1252
Create a new Classpath Variable ( Preferences)which points to your directory and add it to build path.
Use this in your project ( build path - Add Variable)
For Ex: If you want to have C:\MyDev\Libs in your build path
Eclipse-Windows-Preferences-Java-BuildPath-Classpath Variables- New Create a new entry calls MyDevLibs pointing to C:\MyDev\Libs
In your project-build path- configure build path - Libraries (tab) - Add Variable
This should do.
Upvotes: 1