0

Hi everyone iam trying to learn awt and applets. The code below has compiled well but when i run it iam getting an Exception in thread main "Java.lang.NoSuchMethodError". Could any1 pls tell me where i have gone wrong.

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class ButtonTest extends Applet
{
Button b1;
public void init()
{
Button b1= new Button("OK");
add(b1);
}
}

3
Contributors
5
Replies
6
Views
10 Years
Discussion Span
Last Post by Dukane
0

Are you trying to run this program as a console application? Applets are not run the same way console applications are in Java. Java.exe is used to run applications whereas AppletViewer.exe is used to run applets.

Regards,

~Tyler S. Breton

0

Your applet runs just fine in a web browser. But as Tyler said, this program will not run as a console application.

0

Hi Dukane ,

I ve run it using an appletviewer and webbrowser. But iam facing the same problem. I continue to get the same error which i have specified bfore. I ve even checked my browser settings(firefox) and enabled Java for it. I ve also saved both the html and java file in the same directory still the problem continues.

0

Try updating your JRE and JDK. I have the latest version and it works fine for me. I made no changes.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.