Helpful Information
 
 
Category: Java and JSP
program in java

i have the following code:


//: Button1.java
// Putting buttons on an applet
import java.awt.*;
import java.applet.*;
public class Button1 extends Applet {
Button
b1 = new Button("Button 1"),
b2 = new Button("Button 2");
public void init() {
add(b1);
add(b2);
}
} ///:~

when i compile it, everything going alright, but when i exute it the following error appear:
exception in thred main java.lang.nosuchmethoderror: main
why?

don't you need the

public class void main(String args[])

class to run an applet? And an init() method?

how can i do it?

you should be able to add a
public void main( ) {
...
...
}
just before the last bracket so that it is still apart of the class Applet you are using but you already have an init( ) and the main goes below that cause that is the first thing that java will look at.

Jason










privacy (GDPR)