This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
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

Exception in thread "main"...help!

 
Scott Mahoney
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic