how to add multiple jar(s) to classpath?

余生颓废 提交于 2021-01-27 06:18:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!