tags:

views:

43

answers:

2

I would even want it to go recursively multiple folders down and grab all the jar files.

+2  A: 

You can't really do that through the IDE, but what you can do is do it outside the IDE and write a program to manually modify the .classpath file and add the jars.

For example, the .classpath file for your eclipse project is going to look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
 <classpathentry kind="src" path="src/java/main"/>
 <classpathentry kind="src" path="src/java/tests"/>
 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.5.0_17"/>
 <classpathentry kind="lib" path="test_reflib/commons-codec-1.3.jar"/>
 <classpathentry kind="lib" path="test_reflib/commons-collections-3.2.1.jar"/>
 <classpathentry kind="lib" path="test_reflib/commons-fileupload-1.1.1.jar"/>
</classpath>

So what you could do is write a program which scans the directories you pass into it, and manually modifies this .classpath file to contain the jars.

Personally, I never go to the trouble of doing this and just typically put all the jars I need in one folder and include them in the project. Or, if it's something like JBoss jars I need, I just include the ones I want.

dcp
Thanks, in this case i don't have control over how the folders are arranged and so I wrote a script to create this file. It works fine now.
ajay
A: 

Eclipse is really only putting a wrapper around standard Java capabilities, so you can add JARs or directories of classes easily because they correspond to standard Java classpath capabilities.

You could write your own classloader to follow any rules you like (and you will find that some app servers do actually do this.)

Otherwise you would need to follow @dcp's advice and script the edit of the classpath.

djna