Mohib Salahuddin
Mohib Salahuddin

Reputation: 7

Java: Exception in thread “main” java.lang.NoClassDefFoundError (2)

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

Answers (2)

Colin D
Colin D

Reputation: 5661

The classpath is the path to the Java class files, not to the Java source files.

Upvotes: 2

Timothy055
Timothy055

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

Related Questions