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!

Edited 3 Years Ago by Dani: Formatting fixed

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:
<html><applet code="####.class" width=400 height=500></applet></html>
There is nothing to do with main method.

Edited 6 Years Ago by tong1: n/a

So is there anything actually wrong with the code?

And how do I do that pplet viewer thing?

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.

This article has been dead for over six months. Start a new discussion instead.