accoolaryan
hello everyone
i got a problem in java
whenever i compiles any java program it gets compiled correctly,
but while running it it gives an error "java.lang.noclassdeffounderror"
why it happens?
i set the classpath of bin directory and made my working directory where my .java file is saved still its not working why?
You get "NoClassDefFoundError" when JVM doesn't get the .class file of your program. There is no need of setting any classpath.
Simple way, is keep your program at any location in your system then to simply compile the program
Go to "bin" directory" of installed directory and enter
"javac <full path of your Java Program>.java
Now this will by default will generate the .class file at the same location where your Java program resides.
Now for running the program, same go to "bin" directory of installed Java and enter
"java -classpath <path where your .class file exists> <Java Program Name>
Hope it helps ! For more description - you can check this #-Link-Snipped-#
@sarvesh importing "java.lang" is not at all going to help. 😀
If still the problem remains, revert back.
-Sookie