cacn you help me with this one

import java.awt.Graphics;
import java.awt.Color;

import javax.swing.JApplet;

public class Smiley extends JApplet {

    public void paint (Graphics g) {

        super.paint(g);

            g.setColor(new Color (60,10,0));   //outline pants
            g.drawRect(393,275,199,80);       
            g.drawRect(394,276,199,80);


            g.setColor(new Color (145,90,0));  //brown (pants)
            g.drawRect(395,300,197,54);
            g.fillRect(395,300,197,54);

            g.setColor(new Color (255,255,255));
            g.fillRect(395,275,197,50); //fill white (pants)

            g.setColor(new Color (32,5,0));  //stripes
            g.drawRect(408,330,25,6);  //1st
            g.fillRect(408,330,25,6);
            g.drawRect(450,330,25,6);  //2nd    
            g.fillRect(450,330,25,6);
            g.drawRect(505,330,25,6);  //3rd
            g.fillRect(505,330,25,6);
            g.drawRect(550,330,25,6);  //4th
            g.fillRect(550,330,25,6);

            g.setColor(new Color (60,10,0));  //pants2
            g.drawArc(430,350,40,15,180,180);
            g.drawArc(429,349,40,15,180,180);

            g.drawArc(507,350,40,15,180,180);
            g.drawArc(506,349,40,15,180,180);

            g.setColor(new Color (145,90,0));
            g.fillArc(431,350,39,15,180,180);
            g.fillArc(508,350,39,15,180,180);

            g.setColor(new Color (0,0,0));       //shoe left
            g.drawOval(406,400,40,20);
            g.fillOval(406,400,40,20);  
            g.drawRect(441,400,15,20);  
            g.fillRect(441,400,15,20);

            g.setColor(new Color (0,0,0));       //shoe right
            g.drawOval(530,400,40,20);
            g.fillOval(530,400,40,20);  
            g.drawRect(520,400,15,20);  
            g.fillRect(520,400,15,20);


            g.setColor(new Color (255,255,255));
            g.fillArc(440,395,15,10,180,180);
            g.fillArc(521,395,15,10,180,180);

            g.setColor(new Color (60,10,0));  //paa 
            g.drawRect(444,365,10,40);
            g.drawRect(522,365,10,40);
            g.setColor(new Color (255,255,0));
            g.fillRect(445,365,9,40);
            g.fillRect(523,365,9,40);

            g.setColor(new Color (255,255,255));  //socks
            g.drawRect(445,380,8,25);        //left
            g.fillRect(445,380,8,25);
            g.drawRect(523,380,8,25);        //right
            g.fillRect(523,380,8,25);

            g.setColor(new Color (60,10,0));       //lines brown
            g.drawArc(445,380,8,0,180,180);
            g.drawArc(523,380,8,0,180,180);

            g.drawArc(445,395,8,0,180,180);
            g.drawArc(523,395,8,0,180,180);

            g.setColor(new Color (0,128,255));     //lines blue
            g.drawArc(445,387,8,0,180,180);
            g.drawArc(523,387,8,0,180,180);


            g.setColor(new Color (128,0,0)); 
            g.fillArc(460,278,60,50,250,45);    //tie taas
            g.fillArc(476,318,30,50,40,95);     //tie baba

            g.setColor(new Color (32,5,0));     //tie bilog
            g.drawArc(480,285,20,28,180,180);
            g.setColor(new Color (128,0,0)); 
            g.fillArc(480,285,20,28,180,180);

            g.fillArc(445,290,50,50,40,95); //collar left
            g.fillArc(485,290,50,50,40,95); //collar right
            g.setColor(new Color (255,255,255)); //fill wyt collar
            g.fillArc(447,290,46,48,40,95); //collar left
            g.fillArc(487,290,46,48,40,95); //collar right

            g.setColor(new Color (60,10,0));   //outline body
            g.drawRoundRect(389,113,206,188,5,5);
            g.drawRoundRect(390,114,207,188,5,5);
            g.setColor(new Color (255,255,0));
            g.drawRoundRect(390,115,205,185,5,5); //body
            g.fillRoundRect(390,115,205,185,5,5);   

            g.setColor(new Color (0,0,0));
                        g.drawLine(434,145,440,154);          //eyelash left1
            g.drawLine(435,145,441,154);
            g.drawArc(453,140,0,15,0,180);        //eyelash left2
            g.drawArc(454,140,0,15,0,180);
            g.drawLine(470,142,464,154);          //eyelash left3
            g.drawLine(471,142,465,154);

            g.drawLine(504,144,512,154);          //eyelash right1
            g.drawLine(505,144,513,154);
            g.drawArc(524,139,0,15,0,180);        //eyelash right2
            g.drawArc(525,139,0,15,0,180);
            g.drawLine(544,142,536,154);          //eyelash right3
            g.drawLine(545,142,537,154);  

            g.setColor(new Color (136,200,50));  // mga green
            g.drawOval(407,125,18,30);    //1st
            g.fillOval(407,125,18,30);
            g.drawOval(400,158,10,10);    //2nd
            g.fillOval(400,158,10,10);

            g.setColor(new Color (0,0,0));
            g.drawOval(421,150,70,70); //1.left eye
            g.drawOval(420,150,71,71);
            g.drawOval(493,150,70,70); //1.ryt eye 
            g.drawOval(493,150,71,71);

            g.setColor(new Color (255,255,255));
            g.fillOval(422,151,68,69); //fill wyt
            g.fillOval(494,151,68,69);

            g.setColor(new Color (0,0,0));
            g.drawOval(457,178,23,23); //2.left eye
            g.drawOval(456,179,23,23);
            g.drawOval(505,178,23,23); //2.ryt eye
            g.drawOval(506,179,23,23);

            g.setColor(new Color (0,128,255));
            g.fillOval(458,180,21,21); //fill blue          
            g.fillOval(507,180,21,21);          

            g.setColor(new Color (0,0,0));
            g.drawOval(463,184,10,10); //3.left eye
            g.drawOval(512,184,10,10); //3.ryt eye
            g.fillOval(463,184,10,10); //fill black
            g.fillOval(512,184,10,10);

            g.setColor(new Color (0,0,0));  //nose
            g.drawArc(485,190,15,25,300,260);
            g.drawArc(486,191,15,25,300,260);
            g.setColor(new Color (255,255,0));
            g.fillArc(486,191,14,24,300,250);

            g.setColor(new Color (0,0,0));
            g.drawRoundRect(465,245,20,15,5,5); //left tooth
            g.drawRoundRect(495,245,20,15,5,5); //right tooth
            g.setColor(new Color (255,255,255));
            g.fillRoundRect(466,246,19,14,5,5);
            g.fillRoundRect(496,246,19,14,5,5);     

            g.setColor(new Color (0,0,0)); //smile
            g.drawArc(416,184,150,62,180,177);
            g.drawArc(417,184,150,62,180,177);  
            g.drawArc(418,184,150,62,180,177);

            g.setColor(new Color (0,0,0));   //dulo ng smile left
            g.drawArc(413,215,10,5,370,220);    
            g.drawArc(414,216,10,5,370,220);

            g.drawArc(560,215,10,5,370,220);   //dulo ng smile right    
            g.drawArc(561,216,10,5,370,220);

            g.setColor(new Color (60,10,0));  
            g.drawOval(408,208,3,3);// left pimple1
            g.fillOval(408,208,3,3);

            g.drawOval(418,203,3,3);// left pimple2
            g.fillOval(418,203,3,3);

            g.drawOval(415,210,5,3);// left pimple3
            g.fillOval(415,210,5,3);

            g.drawOval(570,208,3,3);// ryt pimple1
            g.fillOval(570,208,3,3);

            g.drawOval(560,206,3,3);// ryt pimple2
            g.fillOval(560,206,3,3);

            g.drawOval(563,210,5,3);// ryt pimple3
            g.fillOval(563,210,5,3);

            g.setColor(new Color (179,89,0));  //left cheekbone 
            g.drawArc(404,200,28,25,350,250);
            g.drawArc(405,201,28,25,350,250);

            g.drawArc(550,203,28,25,300,250);  //right cheekbone
            g.drawArc(551,204,28,25,300,250);









    }
}

Dani AI

Generated

A short, focused note to clarify the stack trace and offer practical fixes.

The error shown — Exception in thread "main" java.lang.NoSuchMethodError: main — means the JVM failed to find an application entry point when you tried to start a class with the java launcher. In this thread the posted Smiley class extends JApplet and does not declare a main method, so trying to run it as a standalone application will produce that error (as already pointed out). The NoSuchMethodError is the runtime signal that the required method is missing; the JVM looks specifically for a public static void main(String[]) (or an acceptable variant) when launching a class. (docs.oracle.com)

Two practical paths forward: run the code as an applet (legacy), or convert it to a Swing application (recommended). Running as an applet still works on older JDKs via appletviewer plus a tiny HTML wrapper, but applets are obsolete — the deployment tools (including appletviewer) were removed from the JDK in JDK 11 and the Applet API has been deprecated/targeted for removal in recent JDK work. For longevity, migrate the drawing into a Swing component and run it from main. (docs.oracle.com)

Minimal, safe patterns you can apply immediately:

public static void main(String[] args) {
    SwingUtilities.invokeLater(() -> {
        JFrame frame = new JFrame("Smiley");
        Smiley app = new Smiley(); // existing JApplet
        app.init(); app.start();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(app);
        frame.setSize(700, 600);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    });
}

Better long term: move the painting into a JPanel and override protected void paintComponent(Graphics g) (call super.paintComponent(g) first). That preserves double buffering and follows Swing best practices; add the panel to a JFrame in main. (docs.oracle.com)

Troubleshooting reminders: when running as an app, ensure you invoke the correct class name or a JAR with a proper Main-Class manifest entry and that you recompile after edits. ’s advice to use an HTML/applet viewer is historically correct, but for modern development convert to a Swing/JPanel-based app for best portability. (docs.oracle.com)

Well, it's pretty simple. You know the main method that you need to have if you're going to kick off from a class? You haven't got one.
Probably you want to run this as an applet - try the appletviewer. You'll want to make a toy html page to enclose it. All it needs to have in the body is the boilerplate html stuff and a tag <applet code="Smiley.class" width=??? height=???> where the ??? are suitable values for the dimensions of your drawing.

Suppose that's called smiley.html, then all you do is run "appletviewer smiley.html"

You could also modify your source code to have a main method which would create a frame and paint that stuff in it, but making an html file is probably easier.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.