| | |
Following tutorials and getting java.lang.NoClassDefFoundError
![]() |
Im reading a book on java, and im on the lesson OOP and java.
This is my code:
This is the error i get:
This is my code:
Java Syntax (Toggle Plain Text)
class Motorcycle { String make; String color; boolean engineState; void startEngine() { if (engineState == true) System.out.println("The engine is already on."); else { engineState = true; System.out.println("The engine is now on."); } } void showAtts() { System.out.println("This motorcycle is a " + color + " " + make); if (engineState == true) System.out.println("The engine is on."); else System.out.println("The engine is off."); } public static void main(String[] args) { Motorcycle m = new Motorcycle(); m.make = "Yamaha RZ350"; m.color = "yellow"; System.out.println("Calling showAtts..."); m.showAtts(); System.out.println("--------"); System.out.println("Starting engine..."); m.startEngine(); System.out.println("--------"); System.out.println("Calling showAtts..."); m.showAtts(); System.out.println("--------"); System.out.println("Starting engine..."); m.startEngine(); } }
This is the error i get:
Java Syntax (Toggle Plain Text)
java.lang.NoClassDefFoundError: Motorcycle/Motorcycle (wrong name: Motorcycle) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at java.net.URLClassLoader.defineClass(URLClassLoader.java:251) at java.net.URLClassLoader.access$100(URLClassLoader.java:55) at java.net.URLClassLoader$1.run(URLClassLoader.java:194) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:187) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) Exception in thread "main"
did you set your classpath?
how to set your classpath on xp
http://www.cs.ucsb.edu/~teliot/Path_and_Classpath.htm
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
![]() |
Similar Threads
- Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error (Java)
- java.lang.NoClassDefFoundError (Java)
- java.lang.NoClassDefFoundError: ??? (Java)
- Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError (Java)
- java.lang.NoClassDefFoundError: java/lang/StringBuilder (Java)
- java.lang.NoClassDefFoundError: JBuilder (Java)
- exception in thread "main" java.lang.NoClassDefFoundError (Java)
Other Threads in the Java Forum
- Previous Thread: Printing Embedded Icons
- Next Thread: accessing clent bios from the server
| Thread Tools | Search this Thread |
911 addball addressbook android api append applet application apps array arrays automation binary bluetooth businessintelligence button card class client code collision component crashcourse css csv database eclipse ee error fractal free ftp game gis givemetehcodez graphics gui html ide image integer integration j2me japplet java javaarraylist javadoc javafx javaprojects jni jpanel julia jvm linked linux list loan machine map method methods migrate mobile netbeans objects oriented output phone physics printf problem program programming project projects radio recursion replaydirector reporting researchinmotion rotatetext scanner se server service set sms software sort sql string swing test textfield threads tree trolltech ubuntu utility windows






