Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JVM Error

 
Dane Richardson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To start I have been trying to learn java for a few weeks now and have been using Eclipse. No Problems there, but I grabbed the book "Head First Java". It wants me to use the command prompt, no problems there, except when I try to run the .class through the JVM. I receive this error: Exception in thread "main" java.lang.NoClassDefFoundError

I have tried several examples throughout the book i.e.


I ran this in eclipse and received no errors the code executes fine. But the exact same code throws the error in command prompt. Any ideas?
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please provide the commands that you used to compile and run the program at the command prompt.
 
Dane Richardson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I first wrote my code then saved it (via notepad) .java. Next in my c.promt I changed my directory. Ran the javac on the file, I got my .class. Then I ran the class file " C:\users\...>java PoolPuzzleOne" thats when I would receive the error. But after a short break and some thought, I went back in the .java and changed the class to "CoolPuzzle". Then repeated the compile and ran the new .class and it ran through the c.promt just fine. No more errors! Problem solved! I would have to guess there was a conflict between the .java and class names being the same.

 
Campbell Ritchie
Sheriff
Pie
Posts: 49776
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You really should tell us the details; without knowing the error message we can't help you. Your PoolPuzzleOne ran all right when I tried it, without any changes, but you are missing a space in anoise. I think line 7 should read System.out.print(" ");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic