• 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" java.lang.NoClassDefFoundError: dice (wrong name: Dice)

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, hello! I'm currently on a path of java enlightenment. I am attempting to learn Java by doing, which I feel fits my learning style excellently!

The only problem is I get lots of errors and warning, and while most I can fix, some I cannot figure out. I am currently working on a piece of code that will allow me to see the result of 2 dice being thrown, both their single values and their summation.



when I compile this, I get not warnings or errors, so I'm assuming the syntax is right. However, when I attempt to run this program (through cmd) I get this doozy:

Exception in thread "main" java.lang.NoClassDefFoundError: dice (wrong name: Dice)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.define.ClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassloader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)

...it goes on for about 7 more lines of stuff I don't understand and then ends with

Could not find the main class: dice. Program will exit.



So, I searched the forums found something with a similar error, but their problem was not having a main() function. I'm fairly certain the "public static void main(String[] args)" is my main () function. The error itself led me to believe I had forgotten to define this program as a Class, but its clearly labeled as Dice.

Any help you could give to point me in the right path is much appreciated! I am very new with java, so please bear through my ignorance
 
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you running the program? My guess is you're typing "java dice" when you should be typing "java Dice".
 
Raine RaineAndrews
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for pointing out my amateur move! It works perfectly now (besides the whole decimal thing, but I think changing the variables to int, instead of double will fix that!)
 
reply
    Bookmark Topic Watch Topic
  • New Topic