且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在类路径中使用通配符添加多个jar?

更新时间:2023-11-18 22:08:28

来自:http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html

类路径条目可以包含基本名称通配符*,这被认为等同于指定目录中所有文件的列表,扩展名为 .jar 或 .JAR.例如,类路径条目 foo/* 指定名为 foo 的目录中的所有 JAR 文件.仅由 * 组成的类路径条目扩展为当前目录中所有 jar 文件的列表.

Class path entries can contain the basename wildcard character *, which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. For example, the class path entry foo/* specifies all JAR files in the directory named foo. A classpath entry consisting simply of * expands to a list of all the jar files in the current directory.

这应该适用于 Java6,不确定 Java5

This should work in Java6, not sure about Java5

(如果它似乎没有按预期工作,请尝试加引号.例如:"foo/*")

(If it seems it does not work as expected, try putting quotes. eg: "foo/*")