November 30th, 2013, 05:08 PM
Java Class wasn't found in project error (using NetBeans)
I am using NetBeans and doing my first graphics applet for a intro to Java class. I an getting a error "happyface.HappyFace class wasn't found in HappyFace project". The error brings up a box to chose a main class but in the box the only option is <no main classes found>.
Here are my steps;
1) create the project by selecting
b) new project
c) category - java
d) project - java application (other choices are java class library, java project with existing sources, java free form project)
f) project name - "HappyFace" (create main class is selected and "happyface.HappyFace" in text box)
2) I paste this exact code into the HappyFace.java file;
public class HappyFace 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);
3) I build and clean successfully
4) I run and get error above
Also, the first line ("import javax.swing.JApplet;") shows an "incorrect package" error with choices to solve as "move class to correct folder" or "change package declaration to "HappyFace". I have chosen both options and neither solve the above issue.
Note - I am clearly new to Java as this issue shows. I just installed JDK and netbeans and have successfully ran the usual "hello world" program.
Any ideas or links to solution would be appreciated. thanks for your time.
November 30th, 2013, 05:17 PM
OK - so I needed to chose "run file" instead of "run project". I am leaving the thread in case anyone else has this issue.
Originally Posted by igilbert