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 found, cant find driven class

 
Ben Hultin
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have compiled my program and recieved this error:



G:\Documents and Settings\ben\Desktop\Desktop\Desktop\Ben\park>java GreedGame
Exception in thread "main" java.lang.NoClassDefFoundError: Greed
at GreedGame.main(GreedGame.java:10)
Caused by: java.lang.ClassNotFoundException: Greed
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more





my diver class begins as so:




my driven class is as so:



There are a number of methods inside the Greed class, but I doubt they part of the problem. I have both java files in the same directory/folder and never had problem with past compiles. been getting errors refering to the driven file that is now "unknown"

I appreciate any help in the matter.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JVM does not find your Greed class, which means that the CLASSPATH is not correctly set. It looks like you're using the default package (which you should avoid), so try to add the current directory to the CLASSPATH: java -cp . GreedGame
 
Campbell Ritchie
Sheriff
Pie
Posts: 49746
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you set a system classpath yourself, you might do well to delete it. If a system classpath has been set for you by another application, try editing that by adding .; to its beginning (for DOS/Windows, for other Operating Systems ..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic