Reputation: 587
I decided to post this question after trying to find an answer for it, and couldn't find one. I'm studying for OCJP and tried few simple codes. This is what I did and need to do.
So after all that was set up compiled TestOne.java then TestTwo.java by setting the flag "classpath" in javac [ javac -classpath ]. Complied. But when I tried to run it gave me an exception "Exception in thread "main" java.lang.NoClassDefFoundError
". Does anyone know what's wrong ?
Upvotes: 0
Views: 100
Reputation: 69
try this
javac -d path cname.java
so write the code like this
javac -d c:\main testone.java javac -d c:\main testtwo.java
c:\main
should exist in your pc
then while executing
java -cp path pn.classname
so whichever class contains main (say test2)
java -cp c:\main package1.testtwo
Upvotes: 0
Reputation: 12042
run the code after compile
compile javac TestTwo.java
run after compile java TestTwo
Upvotes: 1