带冒号和不带冒号“:”的 Java 类路径
我正在学习Java,我有一个怪癖,我认为只有有经验的人才能回答(我已经经历过SO上类似问题的整个列表)。
在 Eclipse 中编译后从命令行运行时,这是有效的
java -classpath : test.class
,并且不
java test.class
指定目录
java -classpath bin test.class
,而是用冒号指定。
java -classpath bin: test.class
据我所知,
- Java 默认情况下检查当前工作目录。
- 仅当您指定超过我只有一条路。
I'm learning Java and I have a quirk that I think only someone with experience can answer (I have been through the whole list of similar problems on SO).
When running from command line after compiling in Eclipse, this works
java -classpath : test.class
and this does not
java test.class
nor specifying the directory
java -classpath bin test.class
but specifying with a colon DOES
java -classpath bin: test.class
It was my understanding that
- Java checked the current working directory by default
- The colon was only used if you were specifying more than one path where I just have one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你想运行“java test”而不是“java test.class”
干杯
You want to run "java test" not "java test.class"
Cheers