I am trying to compile and execute a java program which uses JTidy. I’ve managed to compile the program using the following command:
javac -classpath jtidy-r938.jar @sourcefile
This seems to work just fine. However, when I try to run the program with the following command (Top is the name of the class containing the main portion of the program):
java -classpath jtidy-r938.jar Top
I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: Top
Caused by: java.lang.ClassNotFoundException: Top
...
Could not find the main class: Top. Program will exit.
This is mostly likely a very dumb question with a simple solution, but it is driving me insane. Please help!!
You are removing the path “.” (current directory) from the classpath when you set it.
Try
java -classpath .;jtidy-r938.jar Top.That way it should be able to find your class.