• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is exception in thread "main"

 
Annette L'Heureux
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I have accidently changed some settings or something, because everything I try to run from a command prompt gives me the error
"exception in thread "main": java.lang.NoClassDefFoundError"
What could be the cause of this? I've doubled checked my classpath and my path.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you get that error it means you are trying to run a class that does not have a main() method using the "java" command. To run a servlet you need to use "ServletRunner" not "java".
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mentioned that you have checked your path. The java interpreter is case sensitive. Make sure you are typing in your class name correctly. That's usually the most likely cause for teh JVM not finding the class file your are specifying.
Bosun
 
Annette L'Heureux
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, I don't think it's any of those reasons....
When I first started learning java, I had the "Sam's teach yourself java2 in 21 days" and in it there is a series of exercises you can do. I must have done around 30-40 of them, all of which compiled and ran successfully. Now when I go back to them and try and run them, I get that error. The spelling is all right, and I'm not necessarily trying to run servlets. Even a simple hello world application isn't running.
Maybe it's because it's friday and I'm tired!!! I'm sure I'm just overlooking something.
Thanks for all your help,
Annette
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you typing "java Class1.class" . You have to leave off the .class and jus type "java Class1"
 
Anuj Anand
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Annette have a nice weekend and come back to Java not before Sunday
 
Brett Knapik
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i used to get this error and it was my class path...but you checked that..can't help you.
------------------
I wish there was a button on my monitor to turn up the intellegince.
Theres a button called 'brightness' but it doesn't work
 
mohit joshi
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This classpath business on NT is more tricky then on 95/98. It may not suffice to keep it in the autoexec file, some times it is required that you put it in the classpath Environment variable in the Environment properties of System ( from Control Panel).
in any case, the actual classpath can be checked by typing
echo %classpath% on the console
Hope it helps
 
Sheldon Rego
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey try adding .; in your classpath as well as the path as that will make it the compiler in the present directory as well.
Regrds
Shel
 
Annette L'Heureux
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for all the suggestions!
It seems I was able to fix the problem by completely uninstalling the jdk and reinstalling it. Now everywith works fine! That's good for a monday morning! (Now if only the 25cm of snow they are forcasting for tonight will just not come!!!).
thanks again!
Annette
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic