Write and Execute First Java Program in NetBeans

By | June 30, 2019

Task: How To Write and Execute First Java Program in NetBeans IDE.

Note: In this Simple Java Tutorial we will assume that you have already downloaded and installed Java Development Kit JDK and Net Beans 8.1 IDE or higher.

Short Steps:

Step 1: Start Net Beans IDE
Step 2: Now you will Click on File menu in Net Beans IDE and select New Project
Step 3: In the next step, click on Java from ‘Categories’ and select ‘Java Application’ from ‘projects’.
Step 4: Type ‘HelloWorld’ in the Project Name text box. Afterwards, Click on ‘Finish’.
Step 5: Write the following statement to display ‘Hello World’
System.out.println(“Hello World”);
Step 6: At the end, you will click on the Run Menu and select the Run Project (HelloWorld).

Hence, if there are no errors then you will see the following output: Hello World

Steps With Pictures To Write and Execute First Java Program in NetBeans

Start NetBeans IDE 8.1 or higher

Step 1:
First of all, Start Net Beans IDE

How to write and execute first Java Program in NetBeans IDE

How to write and execute first Java Program in Net Beans IDE

Click on File -> New Project

Step 2:

In the second step, you will click on File menu in the Net Beans IDE and select the ‘New Project’ option.

How to use NetBeans IDE

Use of NetBeans Java IDE

Selecting Java from “Categories” and select Java Application from “projects”

Step 3:

The IDE will show a ‘New Project’ dialog box. Select Java from ‘Categories’ and select ‘Java Application’ from ‘projects’. Click on ‘Next’ button.

Java Programs in IDE

Develop Java application in the IDE

Step: 4 Type Name of Java Project and Select Project Location

Type ‘HelloWorld’ in the Project Name text box.

Note: You should Capitalize first letter of each word. This is due to Java Naming Conventions. A class name will have first letter as capital letter for each word.

Click on ‘Finish’.

Write your first java application and execute in NetBeans

Write your first java application and execute in Net Beans

Step No:5 Edit and Write Code in Default Java Program Template

Step 5:

Write the following statement to display ‘Hello World’

System.out.println(“Hello World”);

Write your first Java program in easy steps

Write your first Java program in easy steps

Save changes to project by File -> Save.

Steps How To Write Java Program in IDE

Java Program how to write

Step 6 – Click on Run Project from Run menu

Step 6:

Then you will click on Run Menu and select Run Project (HelloWorld)

If there are no errors then you will see the following output:

Writing and executing first Java program step wise in netbeans

Writing and executing first Java program

/*
 * How to write and execute your first Java 
program in NetBeans IDE under Windows OS.
 */
package helloworld;
/**
  * @author www.EasyCodeBook.com
 */
public class HelloWorld {

    public static void main(String[] args) {
        // TODO code application logic here
        System.out.println("Hello World");
    }
    
}

Congratulations: You have written your first Java Program. This is the most basic and popular “Hello World” printing program. You can Run the program from the Run menu and view the following output of this Java Program in output pane..

Hello World

After writing and executing this Java program, now you should be able to write a Java Program in NetBeans Java IDE to display Your Name. Try it, now.

You can also read a simple Java Program To Input a Number and Display Its Square

Loading

3 thoughts on “Write and Execute First Java Program in NetBeans

  1. Pingback: Download and Install Java JDK and NetBeans IDE | EasyCodeBook.com

Leave a Reply

Your email address will not be published. Required fields are marked *