gpt4 book ai didi

linux - Java 类路径中 '*' 的特殊含义是什么?

转载 作者:太空宇宙 更新时间:2023-11-04 10:47:06 27 4
gpt4 key购买 nike

'*' 在此示例行中的含义是什么?

javac -classpath .:classes:/opt/pi4j/lib/'*' ...  

最佳答案

引用通配符 * 以阻止 shell 在您输入命令行时尝试展开它。

然而,根据this page from the Oracle Java documentation类路径本身可以评估通配符:

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. Files will be considered regardless of whether or not they are hidden (that is, have names beginning with '.').

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. The order chosen determines whether the classes and resources in foo are loaded before JAR files in foo, or vice versa.

Subdirectories are not searched recursively. For example, foo/* looks for JAR files only in foo, not in foo/bar, foo/baz, etc.

如果你根本不懂*那么你需要关注How to Use Wildcards

关于linux - Java 类路径中 '*' 的特殊含义是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32696526/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com