File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread "main"...help!" Watch "Exception in thread "main"...help!" New topic
Author

Exception in thread "main"...help!

Scott Mahoney
Greenhorn

Joined: Jan 10, 2008
Posts: 3
Hey everyone,

I'm working through the book Head First Java, and I'm having problems getting some of the code to run. It compiles without error, but when I run the class I get this:



Any ideas on how to fix this? I'm thinking I probably don't have something installed properly. I've tried this code on three different computers now, all Windows machines, and I get the same error. If I need to post the program code to help, let me know; I just didn't want to make the post overly long.

Thanks!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Scott Mahoney:
...java.lang.NoClassDefFoundError: game (wrong name: chap5/Game)..

First, Java is case sensitive, so "game" is not the same as "Game." But it also looks like your Game class is in a package (and hopefully a directory) called "chap5."

In this case, the qualified name of the class is really "chap5.Game" which is in the parent directory of "chap5."

So to run this, set the current directory to the parent of the "chap5" directory, and then run with...

...Parent>java chap5.Game


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Exception in thread "main"...help!