如何在类路径中使用通配符添加多个jar? [英] How to use a wildcard in the classpath to add multiple jars?
问题描述
我一直在使用这么多第三方库(jar文件)我的CLASSPATH完全搞砸了,因为我必须包含我使用的每个jar文件的路径。
I have been using so many 3rd party libraries(jar files) that my CLASSPATH is completely messed up as i have to include the path for every single jar file that i use.
我一直想知道是否有办法使用通配符(*)运算符(如* .jar)将所有jar文件包含在文件夹中。但似乎没有用。有没有其他方法可以缩短当前看起来像文章的CLASSPATH;)在我的电脑上?。
I've been wondering if there is a way to include all the jar files in a folder using wildcard(*) operator (like *.jar). But it seems to be not working. Is there any other way that can shorten the CLASSPATH that currently looks like an essay ;) on my PC?.
推荐答案
来自: 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 entryfoo/*
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/*"
)
这篇关于如何在类路径中使用通配符添加多个jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!