• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception in thread "main"...help!

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic