简体   繁体   中英

how to add multiple jar(s) to classpath?

我有超过25个jar文件如何在类路径中添加所有这些文件?

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.

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.

此外,如果类路径太大而无法将其放在命令行上,则可以设置CLASSPATH环境变量(应将其设置为以分号分隔的JAR列表)。

Consider using Maven to manage your dependencies. It'll go a long way to prevent JAR-hell.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM