Why its giving this msg " Exception in thread "main" java.lang.NoSuchMethodError: mai
// Java packages
import java.awt.Graphics; // import class Graphics
import javax.swing.JApplet; // import class JApplet
public class WelcomeApplet2 extends JApplet {
// draw text on applet’s background
public void paint( Graphics g )
{
// call superclass version of method paint
super.paint( g );
// draw two Strings at different locations
g.drawString( "Welcome to", 25, 25 );
g.drawString( "Java Programming!", 25, 40 );
} // end method paint
} // end class WelcomeApplet2
/* when i compfile javac WelcomeApplet2.java its fine it make the class file then run the class file
java WelcomeApplet2
it gives this message
Exception in thread "main" java.lang.NoSuchMethodError: main
*/
Exception in thread "main" java.lang.NoSuchMethodError: main
Hi
I'm getting this error as well when I compile this program with when I try to run this program.
F:\jdk6\bin>javac Motocycle.java
F:\jdk6\bin>java Motocycle
Exception in thread "main" java.lang.NoSuchMethodError: main
class Motorcycle
{
String make;
String color;
boolean enginstate;
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("Starting showAtts....");
m.showAtts();
System.out.println("--------");
System.out.println("Starting engine....");
m.startEngine();
}
void startEngine()
{
if (enginstate == true)
System.out.println("The engine is aready on.");
else
{
enginstate = true;
System.out.println("The engine is now on.");
}
}
void showAtts()
{
System.out.println("This motocycle is a " + color + " " + make);
if ( enginstate = true)
System.out.println("The engine is off ");
else
System.out.println("The engine is on " );
}
}
Found the error -da. Fat Fingers
:SICK:
Saw it right after my submission:
F:\jdk6\bin>javac Motocycle.java
F:\jdk6\bin>java Motocycle
Exception in thread "main" java.lang.NoSuchMethodError: main
Forgot the r in Motocycle / F:\jdk6\bin>javac Motorcycle.java
F:\jdk6\bin>java Motorcycle
The program ran fine
Bye :)