943,985 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1438
  • Java RSS
Dec 26th, 2006
0

Doubt in Applet Program

Expand Post »
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);
}
}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anukool is offline Offline
2 posts
since Dec 2006
Dec 26th, 2006
0

Re: Doubt in Applet Program

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
Reputation Points: 25
Solved Threads: 3
Junior Poster in Training
TylerSBreton is offline Offline
89 posts
since Oct 2006
Dec 26th, 2006
0

Re: Doubt in Applet Program

Your applet runs just fine in a web browser. But as Tyler said, this program will not run as a console application.
Reputation Points: 45
Solved Threads: 28
Posting Whiz in Training
Dukane is offline Offline
282 posts
since Oct 2006
Dec 27th, 2006
0

Re: Doubt in Applet Program

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anukool is offline Offline
2 posts
since Dec 2006
Dec 27th, 2006
0

Re: Doubt in Applet Program

Compiles and runs fine for me.
Reputation Points: 25
Solved Threads: 3
Junior Poster in Training
TylerSBreton is offline Offline
89 posts
since Oct 2006
Dec 27th, 2006
0

Re: Doubt in Applet Program

Try updating your JRE and JDK. I have the latest version and it works fine for me. I made no changes.
Reputation Points: 45
Solved Threads: 28
Posting Whiz in Training
Dukane is offline Offline
282 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: What is causing my problem here
Next Thread in Java Forum Timeline: Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC