Following tutorials and getting java.lang.NoClassDefFoundError

Reply

Join Date: Dec 2004
Posts: 13
Reputation: Diod is an unknown quantity at this point 
Solved Threads: 0
Diod's Avatar
Diod Diod is offline Offline
Newbie Poster

Reading a book and getting java.lang.NoClassDefFoundError

 
0
  #1
Dec 29th, 2004
Im reading a book on java, and im on the lesson OOP and java.

This is my code:
  1. class Motorcycle {
  2. String make;
  3. String color;
  4. boolean engineState;
  5.  
  6. void startEngine() {
  7. if (engineState == true)
  8. System.out.println("The engine is already on.");
  9. else {
  10. engineState = true;
  11. System.out.println("The engine is now on.");
  12. }
  13. }
  14.  
  15. void showAtts() {
  16. System.out.println("This motorcycle is a " + color + " " + make);
  17. if (engineState == true)
  18. System.out.println("The engine is on.");
  19. else System.out.println("The engine is off.");
  20. }
  21.  
  22. public static void main(String[] args) {
  23. Motorcycle m = new Motorcycle();
  24. m.make = "Yamaha RZ350";
  25. m.color = "yellow";
  26. System.out.println("Calling showAtts...");
  27. m.showAtts();
  28. System.out.println("--------");
  29. System.out.println("Starting engine...");
  30. m.startEngine();
  31. System.out.println("--------");
  32. System.out.println("Calling showAtts...");
  33. m.showAtts();
  34. System.out.println("--------");
  35. System.out.println("Starting engine...");
  36. m.startEngine();
  37. }
  38. }

This is the error i get:
  1. java.lang.NoClassDefFoundError: Motorcycle/Motorcycle (wrong name: Motorcycle)
  2. at java.lang.ClassLoader.defineClass0(Native Method)
  3. at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
  4. at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
  5. at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
  6. at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
  7. at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
  8. at java.security.AccessController.doPrivileged(Native Method)
  9. at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
  10. at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
  11. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
  12. at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
  13. at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
  14. Exception in thread "main"
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 13
Reputation: Diod is an unknown quantity at this point 
Solved Threads: 0
Diod's Avatar
Diod Diod is offline Offline
Newbie Poster

Re: Following tutorials and getting java.lang.NoClassDefFoundError

 
0
  #2
Dec 29th, 2004
nm if i use java Motorcycle in command line it works just fine..
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: Following tutorials and getting java.lang.NoClassDefFoundError

 
0
  #3
Dec 30th, 2004
did you set your classpath?

how to set your classpath on xp
http://www.cs.ucsb.edu/~teliot/Path_and_Classpath.htm
Last edited by paradox814; Dec 30th, 2004 at 5:05 am. Reason: added url
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 13
Reputation: Diod is an unknown quantity at this point 
Solved Threads: 0
Diod's Avatar
Diod Diod is offline Offline
Newbie Poster

Re: Following tutorials and getting java.lang.NoClassDefFoundError

 
0
  #4
Dec 30th, 2004
Ok thx, just done that, gotta do a reboot

edit: no luck.. im gonna use JCreator LE(isnt the same as JBuilder), used it before and proved to work so.. thx for the help
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC