This tutorial explains how to write a simple java program, and compile and run it in Netbeans IDEA.

Netbeans Hello World Java application

Following are the steps required to write and run the java program

Open Netbeans

  • Open Apache Netbeans IDE 14 from an Apps in Start in Windows

  • It opens Netbeans

  • Create a java project

Once NetBeans is opened,

  • Go to File -> New Project( Ctrl + Shift +N)
  • Choose the Project Dialog window opened
  • Select Java With Maven project from the Categories panel, and select Java Application from the Projects panel
  • Click the Next button
  • It asks for details Project Name as demoapp, Project location change to desired workspace folder, and click Finish
  • Right Click on the project, the COntext popup opens, Select New, and New, select New Class
  • It opens a window, enter Class Name as “HelloWorld”
  • Write a Java simple hello world-class as given below
/**
 *
 * @author Author
 */
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello world in Netbeans IDE");
    }
}
  • Compile and run the project

Normally, We compile the java file and next run the program using the command line.

In Netbeans, It is not required to compile, as it automatically compiles the program.

Right-click on source code, Select Run File(Shift + F6)

It outputs the message to the console.