Reputation: 7
I am new in Java & creating a student Management program, i have go an below error Exception in thread "main" java.lang.NoClassDefFoundError
but the thing is i also tried to compile & run simple Helloworld.java program, it shows the same error
i refer many of the solutions in stack overflow which belongs to this question but javac -cp.HelloWorld.java or java -classpath.HelloWorld.java
also not workes..
Please help me & guide me why is it so..I think in the code i did not made any mistake.
Upvotes: 0
Views: 1601
Reputation: 5661
The classpath is the path to the Java class files, not to the Java source files.
Upvotes: 2
Reputation: 56
It looks like the problem might be that you're trying to run the java executable on the java file itself.
When you run javac
it emits a bytecode compiled version of your java class for the java executable to run. The bytecode version of your HelloWorld.java class should look like HelloWorld.class. Find this file and instead run java on it, i.e. java HelloWorld.class
Oracle has put up a good example of how to get started here which you may want to check out.
Upvotes: 0