What is wrong with my program?
I have done everything I can do please help me.
public class add extends Applet implements ActionListener
TextField num1 = new TextField( 1000 ); // some objects for the window
TextField num2 = new TextField( 1000 );
Label theAnswer = new Label("0000");
Button addButton = new Button("add");
private JTextArea jTextArea1 = new JTextArea();
public void init()
add( num1 ); // add the objects to the window
add( addButton );
add( theAnswer );
public void actionPerformed(ActionEvent thisEvent)
int first = Integer.parseInt( num1.getText( ) );
int second = Integer.parseInt( num2.getText( ) );
int total = first + second;
theAnswer.setText( " = " + total );
Pinned topic java.lang.NoSuchMethodError: main
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2004-06-30T12:06:34Z at 2004-06-30T12:06:34Z by SystemAdmin
SystemAdmin 110000D4XK4672 Posts
Re: java.lang.NoSuchMethodError: main2004-06-30T12:06:34ZThis is the accepted answer. This is the accepted answer.You probably want to execute the file from command line like "java Add", but this does not work as you really don't have the "main" method defined.
Use the following way to test your applet (I have tried it with your source and it works):
1) Make an HTML file (Add.html) including the following line of code: <APPLET CODE="Add.class" WIDTH="100" HEIGHT="100"> </APPLET>
2) Go to the console window and locate your files. Then type: appletviewer Add.html :)