user3000482
user3000482

Reputation: 205

Getting an error "No main class found" when I tried to run a simple program on NetBeans.

package javaapp;

import javax.swing.JApplet;
import java.awt.Graphics;

public class JavaApp extends JApplet
{
    public void paint(Graphics canvas) 
    {
        canvas.drawOval(100, 50, 200, 200);
        canvas.fillOval(155, 100, 10, 20);
        canvas.fillOval(230, 100, 10, 20);
        canvas.drawArc(150, 160, 100, 50, 180, 180);
    }
}

I tried to run this code which draws a smiley face on a canvas. I ran this code also on Eclipse, where it compiled fine. But on NetBeans, it keeps saying it can't find the main class. Is NetBeans recommended for a beginner like me or should I look for another IDE that better suits for a beginner? I am more fond with the NetBeans because the interface seems more friendly.

Upvotes: 1

Views: 618

Answers (2)

user5830202
user5830202

Reputation:

Right click the project node and choose 'run' from the list. Don't right click the file (run file) as this doesn't work in NetBeans.

Upvotes: 0

dhaval joshi
dhaval joshi

Reputation: 490

In netbeans, right click on the project and chose properties. Under Application > Webstart, there is an option Applet class. specify the full path to your main class (i.e with package names).

Upvotes: 1

Related Questions