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?
Please provide the commands that you used to compile and run the program at the command prompt.
Joined: Mar 14, 2011
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.
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(" ");