Using cygwin on windows 7.
To compile all my files I do:
javac -cp ./antlr-3.2.jar *.java
which works fine. Then I try
java -cp .:./antlr-3.2.jar Interpreter
where interpreter is a .java
file that I know is in the current directory. I thought adding .
to the classpath would fix my problem but I am still getting
Error: Could not find or load main class Interpreter
When you get the message "Could not find or load main class ...", that means that the first step has failed. The java command was not able to find the class. And indeed, the "..." in the message will be the fully qualified class name that java is looking for.
When the JVM is unable to locate the main class, it's often because it's looking for the corresponding . class files in the wrong classpath. Of course, the way to rectify this problem is to manually specify the classpath by either using packages or specifying the classpath.
Even though you are running under cygwin, the java.exe is still a windows program.
It needs ;
as class path delimiter. Try ,
java -cp ".;./antlr-3.2.jar" Interpreter
or
java -cp .\;./antlr-3.2.jar Interpreter
You need to escape or quote the classpath correctly so that it is not interpreted by shell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With