954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Applet will compile, won't run because of main method issue

So I'm making a smiley face. It' compiles just fine, and at the run time it says "process completed" but the applet doesn't pop up. I have absolutely no idea what's going on!!

Here is the error message:

java.lang.NoSuchMethodError: main
Exception in thread "main"
Process completed.

Here is the beginning part of my code:

/**
/**
* @(#)snow2.java
*
*
* @author
* @version 1.00 2010/9/25
*/

import java.awt.*;

public class snow2 extends java.applet.Applet {

/** Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
// TODO start asynchronous download of heavy resources
}

public void paint (Graphics page)
{
final int MID = 130;
final int TOP = 50;
setBackground (Color.cyan);
page.setColor (Color.blue);
page.fillRect (0, 175, 300, 50); // ground
page.setColor (Color.yellow);
page.fillOval (260, 40,80, 80); // sun
page.setColor (Color.white);
page.fillOval (MID-20,TOP, 40, 40); // head
page.fillOval (MID-35,TOP+35, 70, 50); // upper torso
page.fillOval (MID-50,TOP+80, 100, 60); // lower torso
page.setColor (Color.red);
page.fillOval (MID-3,TOP+50, 6, 6); // button
page.fillOval (MID-3,TOP+60, 6, 6); // button
page.setColor (Color.black);
page.fillOval (MID-10,TOP+10, 5, 5); // left eye

Please if you can help me in anyway, I'd greatly appreciate it!

javanewb101
Newbie Poster
3 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

You should use a browser or the command: appletviewer in DOS window to open a html file where the applet code, i.e. the file of the applet code is in the same directory/folder, is available:

tong1
Posting Whiz
358 posts since Jul 2010
Reputation Points: 34
Solved Threads: 72
 

So is there anything actually wrong with the code?

And how do I do that pplet viewer thing?

javanewb101
Newbie Poster
3 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

I guess nothing wrong with your applet code. At this stage please read some tutorial to find out how to run an applet program.
To run an applet, you need a Web page that includes it. A Web page is a text file that can be displayed by a Web browser.

http://www.cs.colostate.edu/helpdocs/JavaInDOS.html

tong1
Posting Whiz
358 posts since Jul 2010
Reputation Points: 34
Solved Threads: 72
 

oh i thought that after you put it into java, it was just supposed to like pop up or something...after you like run it.

javanewb101
Newbie Poster
3 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: