The following program is throwing error:
public class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
CLASSPATH C:\Program Files\Java\jdk1.6.0_18\bin\
Path C:\Program Files\Java\jdk1.6.0_18\bin\
JAVAHOME C:\Program Files\Java\jdk1.6.0_18\bin
Can you please tell me the root cause?
Had the same problem tried above solutions but none worked. I had to go through my java code only to find that the main function could not be recognised since there was no space btw it and (String) ie initial code:
working code.
Hope I helped someone.
Easy & Simple solution: I solved this problem (NetBeans) by exporting the original project into zip file, deleting the original project directory and importing the project back from the zip file.
The Problem here is the setting the environment and the running of the class file. a. To set the environment path run the following command: set path=C:\Program Files (x86)\Java\jdk1.7.0\bin b. run the program from the package like com.test.TestJavaClass
Command: java com.test.TestJavaClass
The general issue here is we run it either from inside the package like src/package/name. We should not include src, package name is enough.
If your package is
helloworld
you would go to parent dir of your package then run:I had this proplem I used maven. I just click maven projects ant then name
project-> plugins -> clean -> and button run
.The javadoc of NoClassDefFounError itself would be a good start (here), and then I'll suggest you clean and rebuild your project.