Enable multiple cans with classpathentry

I have an eclipse.classpath file that looks like this:

<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> <classpathentry kind="lib" path="/libraries/jee/servlet-api.jar"/> <classpathentry kind="lib" path="/libraries/junit/junit-4.6.jar"/> <classpathentry kind="lib" path="/libraries/log4j/log4j-1.2.15.jar"/> </classpath> 

I would like to add the whole jars directory to the class path - I like eclipse (or rather, our ant-based build process, which uses the .classpath format) to know several jars that are in the same directory without specifying them directly. How can i do this?

+6
java classpath eclipse jar
source share
7 answers

I'm not sure eclipse can do it myself.

You can try

  • Go to Maven for your build system and then eclipse: the eclipse command will create a .classpath file for you.
  • Get ant to change .classpath after build. In the end, it's just xml
+3
source share

My colleague has implemented a classpath container that recursively searches for banks in a given directory in the workspace, take a look at http://openscada.org/2010/05/31/adding-a-directory-as-class-path-to-eclipse/

The update site can be found at http://repo.openscada.org/p2/bob/R

The plugin is licensed unter LGPL V3, and you can find the source code in git: //git.openscada.org/ ( <a2> )

+2
source share

Eclipse is not working, I'm afraid. The best solution I can think of is to create a .classpath file from a script that scans the can directory.

+1
source share

There is a developerworks article that shows how to implement a custom path class container that exposes the contents of a directory. You need to register to view the article and download sources.

+1
source share

IVY contains an ANT task that will create an XML file that will indicate the location of the jar dependencies that it manages.

http://ant.apache.org/ivy/history/latest-milestone/use/artifactreport.html

It would be very simple to combine this with the XSLT stylesheet to generate the Eclipse.classpath file later.

+1
source share

Try http://ant-eclipse.sourceforge.net this works pretty well. The active fork is at https://github.com/javajoesb/ant-eclipse

+1
source share

Put all the cans in the same library folder

use javac -classpath c: \ com \ whichever \ libraries * program1.java

0
source share

All Articles