Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Windows 7 上使用 cygwin。
要编译我的所有文件,我会:
javac -cp ./antlr-3.2.jar *.java
效果很好。然后我尝试
java -cp .:./antlr-3.2.jar Interpreter
其中解释器是.java我知道在当前目录中的文件。我认为添加.到类路径可以解决我的问题,但我仍然得到
.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 解释。