如何一次性包含CLASSPATH中特定目录中的所有jar? [英] How to include all the jars present at a particular directory in the CLASSPATH in one go?
问题描述
我的应用程序使用的特定目录中有数百个罐子。所以我认为很难将每个罐子逐个添加到类路径中。所以有任何命令或任何方式,以便我可以一次性添加所有的罐子。一些 * .jar
应该添加所有的罐子。
I have around hundreds of jars at a particular directory which my application uses. So I thought its hard to add each jars one by one to the classpath. So is there any command or any way so that i can add all the jars at one go. some *.jar
should add all the jars.
推荐答案
是的,从Java6开始,您可以使用通配符。请参阅了解类路径通配符一节
Yes, you can use a wildcard, as of Java6. See the section on "Understanding class path wildcards"
类路径条目可以包含基本名称通配符
*
,被认为等同于指定目录中扩展名为.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.
在Java 6之前,你必须单独指定它们。
Prior to Java 6, you had to specify them all individually.
这篇关于如何一次性包含CLASSPATH中特定目录中的所有jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!