For example, the class path entry foo/*
specifies all JAR files in the directory named foo. (例如,类路径条目foo/*
指定目录foo中的所有JAR文件。)
A classpath entry consisting simply of *
expands to a list of all the jar files in the current directory. (仅由*
组成的类路径条目将扩展为当前目录中所有jar文件的列表。)
A class path entry that contains *
will not match class files.
(包含*
类路径条目将与类文件不匹配。)
To match both classes and JAR files in a single directory foo, use either foo;foo/*
or foo/*;foo
. (要在单个目录foo中匹配类和JAR文件,请使用foo;foo/*
或foo/*;foo
。)
The order chosen determines whether the classes and resources in foo
are loaded before JAR files in foo
, or vice versa. (选择的顺序确定是否在类和资源foo
中之前在JAR文件加载foo
,或反之亦然。)
Subdirectories are not searched recursively.
(子目录不是递归搜索的。)
For example, foo/*
looks for JAR files only in foo
, not in foo/bar
, foo/baz
, etc. (例如, foo/*
仅在foo
查找JAR文件,而不在foo/bar
, foo/baz
等中查找。)
The order in which the JAR files in a directory are enumerated in the expanded class path is not specified and may vary from platform to platform and even from moment to moment on the same machine.
(在扩展的类路径中枚举目录中JAR文件的顺序未指定,并且可能因平台而异,甚至在同一台计算机上有时也有所不同。)
A well-constructed application should not depend upon any particular order. (结构良好的应用程序不应依赖于任何特定顺序。)
If a specific order is required then the JAR files can be enumerated explicitly in the class path. (如果需要特定顺序,则可以在类路径中显式枚举JAR文件。)
Expansion of wildcards is done early, prior to the invocation of a program's main method, rather than late, during the class-loading process itself.
(通配符的扩展是在类加载过程本身的早期,而不是在程序的主要方法调用之前完成的。)
Each element of the input class path containing a wildcard is replaced by the (possibly empty) sequence of elements generated by enumerating the JAR files in the named directory. (输入类路径中包含通配符的每个元素都将由(可能为空)元素序列替换,这些元素序列是通过枚举命名目录中的JAR文件生成的。)
For example, if the directory foo
contains a.jar
, b.jar
, and c.jar
, then the class path foo/*
is expanded into foo/a.jar;foo/b.jar;foo/c.jar
, and that string would be the value of the system property java.class.path
. (例如,如果目录foo
包含a.jar
, b.jar
和c.jar
,则类路径foo/*
将扩展为foo/a.jar;foo/b.jar;foo/c.jar
,以及该字符串将是系统属性java.class.path
的值。)
The CLASSPATH
environment variable is not treated any differently from the -classpath
(or -cp
) command-line option.
(CLASSPATH
环境变量与-classpath
(或-cp
)命令行选项没有任何区别。)
That is, wildcards are honored in all these cases. (也就是说,在所有这些情况下都应使用通配符。)
However, class path wildcards are not honored in the Class-Path jar-manifest
header. (但是,类路径通配符在Class-Path jar-manifest
标头中不被接受。)