“java -classpath .:”是什么意思?意思是?
文档中没有提到这一点 ,但是在没有 :
的情况下调用它时,我得到了 ClassNotFoundException。
全线:
java -classpath .:soy-20100708.jar HelloWorld
但这也有效......
java -classpath :soy-20100708.jar HelloWorld
There is no mention of this in the documentation, but I get a ClassNotFoundException when calling it without the :
.
Full line:
java -classpath .:soy-20100708.jar HelloWorld
This works too though...
java -classpath :soy-20100708.jar HelloWorld
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这 ”。”表示也搜索当前目录,“:”是路径分隔符。正如此网站中所述,分隔符与平台相关:
The "." means the current directory is searched too, the ":" is your path separator. As described on this website, the separator is platform-dependent:
冒号“:”在unix环境下是路径分隔符,而在windows下分号“;”分隔路径。即你可以写:
它会加载两个 jar 到路径。
而句点“.”句点代表当前目录。请注意,目录仅搜索 *.class 文件,而不搜索包。
以“:”开头的版本没有被文档覆盖(据我所知),所以它可能只是偶然工作(可能将当前目录添加到类路径)
编辑:
我刚刚发现, dir/* 找到 JAVA 6 中 dir 中的所有 jar
The colon ":" is path separator in unix environment, while on windows the semicolon ";" separates the path. i.e. you can write:
And it loads two jars to path.
While period "." period stands for current directory. Beware that directories are search only for *.class files not packages.
the version starting with ":" is not covered by documentation (as far as i know) so it just probably works by accident (pobably adding current dir to classpath aswel)
EDIT:
I just found out, that dir/* finds all jars in dir in JAVA 6
:
用于分隔类路径条目。因此
.:soy-20100708.jar
的意思是“在当前目录和soy-20100708.jar
内部搜索”。第二个变体“:soy-20100708.jar”没有特殊含义(格式错误)。它可能可以以某种方式解释,但我不知道有什么特殊含义。
您可以发布
jar
文件的内容吗?它包含哪些文件以及在哪些目录中?:
is used to separate classpath entries.Therefore
.:soy-20100708.jar
means "search in the current directory and insidesoy-20100708.jar
".The second variant ":soy-20100708.jar" has no special meaning (it is malformed). It might be interpreted somehow, but I'm not aware of any special meaning.
Can you post the content of the
jar
file? Which files does it contain and in which directories?