File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes JVM Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JVM Error " Watch "JVM Error " New topic

JVM Error

Dane Richardson

Joined: Mar 14, 2011
Posts: 2
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

Joined: Jun 01, 2010
Posts: 618
Please provide the commands that you used to compile and run the program at the command prompt.
Dane Richardson

Joined: Mar 14, 2011
Posts: 2
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

Joined: Oct 13, 2005
Posts: 46375
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(" ");
I agree. Here's the link:
subject: JVM Error
It's not a secret anymore!