Results 1 to 2 of 2
- 08-06-2007, 04:53 AM #1
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
exception in thred main java.lang.nosuchmethoderror: main
Hi, I have the following code:
When i compile it, everything going alright, but when i execute it the following error appear:Java Code: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); } }
exception in thread main java.lang.nosuchmethoderror: main
why?
Thanks.
- 08-06-2007, 09:11 AM #2
At the prompt you run an application with >java MyClass.java
For an applet you use the appletviewer: >appletviewer MyApplet.java
and for this to work your java/source file must have an applet tag in it, like so
Java Code:// <applet code="Button1" width="200" height="200"></applet> 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); } }
Similar Threads
-
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
By paul in forum New To JavaReplies: 8Last Post: 03-05-2011, 03:53 AM -
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main
By barney in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:10 AM -
Exception in thread "main" java.lang.NoClassesDefFoundError
By tommy in forum New To JavaReplies: 1Last Post: 07-31-2007, 01:54 PM -
Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
By romina in forum New To JavaReplies: 1Last Post: 07-25-2007, 10:55 PM -
ArrayList: Exception in thread "main" java.lang.NullPointerException
By susan in forum New To JavaReplies: 1Last Post: 07-16-2007, 06:32 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks