问题
I am having more than 25 jar files how to add all of them in a classpath?
回答1:
Separate them with a colon / semicolon (:
/ ;
) on *nix / win
But it would be way easier to use an IDE (Eclipse, NetBeans) to handle the classpath for you.
回答2:
If all the jar files are in the same folder, as of jdk6, Java supports classpath wildcards. http://download.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html
So you can use something like,
/path/to/jar/*
Also consider having a separate classpath for each project.
回答3:
Additionally, if the classpath is so big that you can't put this on a command line, you can set the CLASSPATH
environment variable (which should be set to the semicolon-separated list of JARs).
回答4:
Consider using Maven to manage your dependencies. It'll go a long way to prevent JAR-hell.
回答5:
I use eclipse, so there is a for me to first put them into a folder. After which if I need to add it to build path, I just go to the build path option to browse to the folder and select all. You can also import them easily by browsing to the folder and select all too.
来源:https://stackoverflow.com/questions/3387534/how-to-add-multiple-jars-to-classpath