Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: ERROR:'Exception in thread "main" java.lang.NoSuchMethodError: main "

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ERROR:'Exception in thread "main" java.lang.NoSuchMethodError: main "

    Hello Guys! I need some help in my code Im new in making java programming.here's is my problem i would like to run an applet but i got this line error "'Exception in thread "main" java.lang.NoSuchMethodError: main " i use command prompt it is ok to compile if i try to type D:\javac AnitaApplet.java but when i ll go to the next type like java AnitaApplet then i got the error..

    my code is this..
    import java.awt.*;
    import java.applet.*;
    public class AnitaApplet extends Applet
    {	
    	public void paint(Graphics g)  
    	{	
    		g.drawString("Jakjes Bakery",15,20);
    		g.drawString("Naga City",15,30);
    		g.drawString("Philippines",15,40);
    		g.drawString("Emailto:jjakjes@yahoo.com",15,50);
    	}
     
    }
    pls help me i want to understand more about programming in java. thanks!
    Last edited by copeg; November 10th, 2010 at 09:59 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: ERROR:'Exception in thread "main" java.lang.NoSuchMethodError: main "

    You are trying to run an applet like an application. Applications require a main method, applets don't. Try running using appletviewer rather than java.

  3. #3
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: ERROR:'Exception in thread "main" java.lang.NoSuchMethodError: main "

    You compile it as applet, not as an application. Applications require a main method.

    Also, usually I've seen people extend JApplet

    It's a subclass of Applet.

    JApplet (Java 2 Platform SE v1.4.2)

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: ERROR:'Exception in thread "main" java.lang.NoSuchMethodError: main "

    Quote Originally Posted by javapenguin View Post
    You compile it as applet, not as an application.
    Not exactly...the compilation is the same, but they run differenly, in this case it needs to be run as an applet

  5. The Following User Says Thank You to copeg For This Useful Post:

    javapenguin (November 10th, 2010)

  6. #5
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: ERROR:'Exception in thread "main" java.lang.NoSuchMethodError: main "

    thank you for the reply.. my question is how do i run it using appletviewer and if theres a main how do i indicate it in my code?? please advice thanks!

  7. #6
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: ERROR:'Exception in thread "main" java.lang.NoSuchMethodError: main "


  8. #7
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: ERROR:'Exception in thread "main" java.lang.NoSuchMethodError: main "

    ok thank for all advise now i see the diffences of running of apllication and an applet.. =) thanks alot!!

Similar Threads

  1. Replies: 16
    Last Post: August 27th, 2010, 03:30 PM
  2. Replies: 2
    Last Post: March 26th, 2010, 11:22 AM
  3. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 08:35 AM
  4. Please help! Exception in thread "main" java.lang.NullPointerException
    By Arutha2321 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 18th, 2009, 02:25 AM
  5. Replies: 1
    Last Post: October 25th, 2009, 11:54 AM