gpt4 book ai didi

java - 错误 : Could not find or load main class - Java cygwin

转载 作者:IT王子 更新时间:2023-10-29 00:16:46 26 4
gpt4 key购买 nike

在 Windows 7 上使用 cygwin。

为了编译我所做的所有文件:

javac -cp ./antlr-3.2.jar *.java

效果很好。那我试试

java -cp .:./antlr-3.2.jar Interpreter

其中 interpreter 是一个 .java 文件,我知道它在当前目录中。我认为将 . 添加到类路径可以解决我的问题,但我仍然得到

Error: Could not find or load main class Interpreter

最佳答案

即使你在cygwin下运行,java.exe仍然是一个windows程序。

它需要;作为类路径分隔符。试试看,

java -cp ".;./antlr-3.2.jar" Interpreter

java -cp .\;./antlr-3.2.jar Interpreter

您需要正确转义或引用类路径,这样它就不会被 shell 解释。

关于java - 错误 : Could not find or load main class - Java cygwin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16140668/

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