This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception in thread "main"...help!
 
Similar Threads
Import *.jar File in Java Code
Not able to run a class file
gettin error while running program
Can't even run a "Hello World" program
XMLBeans compilation error