Im reading a book on java, and im on the lesson OOP and java.

This is my code:

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.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"

nm if i use java Motorcycle in command line it works just fine..

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.