Java Quick Start Tutorial

Last reviewed on 2019-01-25

Welcome to Apache NetBeans IDE!

In this tutorial, which should take about 10 minutes to complete, you are given a quick introduction to the basic Java development workflow in NetBeans IDE.

The aim of this tutorial is to get you started with Java development in NetBeans IDE. To get started understanding and working with the Java language itself, see the Java Tutorials.

Setting Up the Project

Take the steps below to set up a new Java project.

  1. In the IDE, choose File > New Project or click the "New Project" button in the toolbar.

  2. In the New Project wizard, expand the Java category and select Java Application as shown in the figure below. Then click Next.

proj wizard small
The first time you create a new Java project, you will be prompted to download and enable support for Java. Follow the prompts and install as recommended by the wizard.
  1. In the Name and Location page of the wizard, do the following (as shown in the figure below):

    • In the Project Name field, type HelloWorldApp.

    • In the Create Main Class field, type helloworldapp.HelloWorldApp.

proj wizard2 small

Click Finish.

The project is created and opened. You should see the following components:

  • Projects window: Contains a tree view of the components of the project, including source files, libraries that your code depends on, and so on.

  • Source Editor: Contains files, where most of your work will be done, currently with a file called HelloWorldApp open.

  • Navigator: Useful for quickly navigating between elements within the selected class.

proj opened small

Adding Code to the Generated Source File

A skeleton main class has been created for you. You can add a "Hello World!" message by replacing this line…​

// TODO code application logic here

…​with this line:

System.out.println("Hello World!");

Save the change by choosing File > Save.

Notice that when you press Ctrl-Space, the editor shows you multiple ways of completing the code at the cursor, as well as related documentation:

editor cc small

For a full description of editor assistance features, see Code Assistance in the NetBeans IDE Java Editor: A Reference Guide.

Running the Application

Right-click the project and choose Run or choose Run Project under the Run menu.

In the Output window (which can be opened from the Window menu), you should see the below.

run output

Congratulations! Your application works.

You can view the build output by opening the Files window (from the Window menu) and expanding the project node.

You now know how to accomplish the most common Java development tasks. To learn the complete Java development workflow, including testing and debugging, see Developing General Java Applications.