1.3.2 – Executing java program in NetBeans

by subbu on December 29, 2014

In the previous session we have installed NetBeans. Now we will see how we can write and execute a simple java program in NetBeans IDE.

Open the NetBeans IDE either by double click on NetBeans icon which is on the desktop or by selecting from the start menu

NetBeans icon on desktop

Select File – New Project

NetBeans newfile

It prompts for the project name, project location and class name

The default name of project is “JavaApplication1”, the default class name is also “JavaApplication1” and the default location is the “NetBeansProjects” under Documents.

NetBeans IDE

Here I am keeping the location of project as same and changing the name of project to “app1” and main class name to “app1.Demo”. If you want you can select different location.

NetBeans-filelocation

Select Finish to proceed

Select “java” as the category and “Java Application” as the type of project to create a simple java application and select “Next” to proceed.

NetBeans Application type

According to the project name and the main class name that we have supplied, NetBeans automatically creates a simple program structure

Here an empty class Demo is created under the app1 package.

NetBeans Application type

Now we can type the program code within the main() of class Demo

package app1;
public class Demo
{
 public static void main(String[] args)
 {
   System.out.println("Hello World");
 }
}

Execute the program either by selecting run button or by using f6

NetBeans-executing

{ 0 comments… add one now }

Previous post: