Create First Java console Project in NetBeans

Java Console Project in NetBeans

For Java Development normally people use NetBeans or Eclipse. And JDK (java development kit) I use NetBeans 8.1 and JDK of the same type.So first of all for my very first project I just install both NetBeans and JDK from Oracle official website. And after installation complete, we are going to create our first Java project.

Now run NetBeans which possible on desktop or start menu

start NetBeans

Step 1:

It may take a couple of minutes to load. After loading probably, the start page will open which is something like

NetBeans StartPage

Now Choose File or Alt+F and the File menu will open on the top-right of the screen and from there select New Project or crt+shf+N Because this time; we will create a new project.

NetBeans New Project

Step 2:

After Selecting New Project, a new popup window will open.

NetBeans choose project type

In this window, there are two fields one is Project Category, and other is projects type. We are developing Java Project so select Java from categories and from project select Java Application, which contains main function of the project and then click next.

Step 3:

Name and Location of new project

Then next window will open where you have to put the name and location of your project by default was set to the location where you install NetBeans if you want to change it, change the location manually or browse it using the button next to project location option.

The project name is any name you want to give to the project and then click Finish.

This will create a new folder in your workspace and show you the text area to write your code.

Step 4:

Now it’s time to start the main part of the project which is coding.

Here is the tab name same as you gave in the project name, option in the previous panel, like in this case it’s Myfirstproject.java. As it’s a Java project, so it has extension of .java and this file contain the package name main function by default

NetBeans text area window

1

2

3

4

5

6

7

8

9

packagemyfirstproject;

publicclassMyFirstProject{

publicstaticvoidmain(String[]args){

}

}

If you just want to run this just press F6 or press Run Button (green button on upper bar) and as we have nothing to show or print so our project will run successfully but show nothing.

Understanding Code:

Now Consider the above default code and try to understand it the first line is Package myfirstProject; else all the thing written between /* */ is comment area in Java and they have no effect on the output or execution of the project.

The package name is same which we gave while project setup and the package is the technique to organize and manage Java classes because one project may have many classes, so the classes under same package name are categorized by their type.

The next Line Public class MYFirstProject{ } is the first class of our java program as the Java is Object Oriented Language, so it uses classes.

First, we Use Access Specifiers to tell the program the scope of the class, in that case, its public mean’s it’s visible everywhere in the program.

Next, We use the class keyword to show that it’s class.

And at the last select some name for the class. Here it’s same which we add while project setup.

Inside the MyFirstProject class, there is the main function of our program.