Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-06-2003, 09:09 AM   PM User | #1
Aymen++
Regular Coder

 
Join Date: Nov 2002
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Aymen++ is an unknown quantity at this point
program in java

i have the following code:
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?
Aymen++ is offline   Reply With Quote
Old 03-06-2003, 11:52 AM   PM User | #2
bcarl314
Mega-ultimate member


 
Join Date: Jun 2002
Location: Winona, MN - The land of 10,000 lakes
Posts: 1,855
Thanks: 1
Thanked 45 Times in 42 Posts
bcarl314 will become famous soon enough
don't you need the

public class void main(String args[])

class to run an applet? And an init() method?
bcarl314 is offline   Reply With Quote
Old 03-06-2003, 03:13 PM   PM User | #3
Aymen++
Regular Coder

 
Join Date: Nov 2002
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Aymen++ is an unknown quantity at this point
how can i do it?
Aymen++ is offline   Reply With Quote
Old 03-06-2003, 09:41 PM   PM User | #4
Jason
Regular Coder

 
Join Date: Feb 2003
Location: California
Posts: 925
Thanks: 0
Thanked 0 Times in 0 Posts
Jason is an unknown quantity at this point
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
Jason is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:02 PM.


Advertisement
Log in to turn off these ads.