NetBeans 7.1
Let’s say I want to run this simple HelloWorld code from wikipedia:
import java.applet.Applet;
import java.awt.*;
// Applet code for the "Hello, world!" example.
// This should be saved in a file named as "HelloWorld.java".
public class HelloWorld extends Applet {
// This method is mandatory, but can be empty (i.e., have no actual code).
public void init() { }
// This method is mandatory, but can be empty.(i.e.,have no actual code).
public void stop() { }
// Print a message on the screen (x=20, y=10).
public void paint(Graphics g) {
g.drawString("Hello, world!", 20,10);
// Draws a circle on the screen (x=40, y=30).
g.drawArc(40,30,20,20,0,360);
}
}
I click:
- NewProject/Java/JavaApplication
- Set project name to: “AppletHelloWorld”, Finish
- click on AppletHelloWorld.java, I see this:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package applethelloworld;
/**
*
* @author Admin
*/
public class AppletHelloWorld {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
}
- I copy/past the code and change “public class HelloWorld extends Applet” to “public class AppletHelloWorld extends Applet”
import java.applet.Applet;
import java.awt.*;
// Applet code for the "Hello, world!" example.
// This should be saved in a file named as "HelloWorld.java".
public class AppletHelloWorld extends Applet {
// This method is mandatory, but can be empty (i.e., have no actual code).
public void init() { }
// This method is mandatory, but can be empty.(i.e.,have no actual code).
public void stop() { }
// Print a message on the screen (x=20, y=10).
public void paint(Graphics g) {
g.drawString("Hello, world!", 20,10);
// Draws a circle on the screen (x=40, y=30).
g.drawArc(40,30,20,20,0,360);
}
}
- click Run, “BUILD SUCCESSFUL (total time: 0 seconds)”, nothing appears on the screen
- Click “Clean and Build Main Project”, click Run again, get an error “applethelloworld.AppletHelloWorld class wasn’t found in AppletHelloWorld project; select the main class”.
I guess, I clicked something wrong along the way 
I was checking several tutorials but I always stumbled on some differences (like there is no “Run as Applet” option in NetBeans 7.1 or the option they select in the tutorial does not exist)