Java Quick Start Tutorial
Last reviewed on 2019-04-06
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 with Maven in NetBeans IDE. Though not needed to complete this tutorial, to get started understanding and working with the Java language itself, see the Java Tutorials, and to understand Maven, the Apache Maven Website.|
Setting Up the Project
Take the steps below to set up a new Java project.
In the IDE, choose File > New Project or click the "New Project" button in the toolbar.
In the New Project wizard, select Java Application, as shown in the figure below. Then click Next.
|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.|
In the Name and Location page of the wizard, type
HelloWorldAppin the Project Name field, (as shown in the figure below):
The project is created and opened.
Creating a Java Source File
Right-click the package name and choose New | Java Class, (as shown in the figure below):
In the New Java Class wizard, type
Main in the Class Name field, (as shown in the figure below):
The Java source file is created and opened.
You should see the following components, (as shown in the figure below):
Projects window: Top left, contains a tree view of the components of the project, including source files, libraries that your code depends on, and so on.
Source Editor: Central area, contains files, where most of your work will be done, currently with a Java source file called
Navigator: Lower left, useful for quickly navigating between elements within the selected class.
Adding Code to the Java Source File
A skeleton main class has been created for you. Let’s add some basic content to produce a 'hello world' message.
Between the braces, type
psvmand press Tab. You should now see
public static void mainstatement.
public static void mainstatement, type
soutand press Tab. You should now see a
Within the quotation marks, type
You should now see the following:
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:
For a full description of editor assistance features, see Code Assistance in the NetBeans IDE Java Editor: A Reference Guide.
Running the Application
Make sure to save the Java source file, right-click the project and choose Run or choose Run Project under the Run menu. Click Select Main Class.
In the Output window (which can be opened from the Window menu), you should see the below.
Congratulations! Your application works.
You can view the build output by opening the Files window (from the Window menu) and expanding the
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.