Intellij Idea - Create First Java Project

It is time we got a hands-on experience with IntelliJ. In this chapter, we will create our first Java Project. We will write and execute the traditional Hello World program. This chapter explains the compilation and running of Java application.
For anything related to development, a developer has to create a new project with IntelliJ. Let us follow these steps to create a project −
Launch IntelliJ.
Launch IntelliJ.
Go to File → New → Project menu.
Go to File → New → Project menu.
Select the Java project and appropriate SDK and click on the Next button.
Select the Java project and appropriate SDK and click on the Next button.
If you want to create a Java class with the main method, then select Create Project from the template checkbox.
If you want to create a Java class with the main method, then select Create Project from the template checkbox.
Select the command line app from the dialog box shown below and continue.
Select the command line app from the dialog box shown below and continue.
Enter the project name and the directory location.
Enter the project name and the directory location.
Click on the Finish button.
Click on the Finish button.
A package is created under Java project and can be created separately, or at the same time of creating a class. Let us follow these steps to create a package −
Go to the project perspective.
Go to the project perspective.
Right-click on Project, select the New->Module option.
Right-click on Project, select the New->Module option.
The new module window will be similar to the new project. Select the Java option and appropriate SDK and click on the Next button.
The new module window will be similar to the new project. Select the Java option and appropriate SDK and click on the Next button.
Enter the module name.
Enter the module name.
Click on the Finish button.
Click on the Finish button.
In this section, we will learn how to create a Java class. A Java class can be created under a Java module. Follow these steps to create a module −
Go to the Project perspective.
Go to the Project perspective.
Expand Project and select the src directory from the module.
Expand Project and select the src directory from the module.
Right click on it; select the New->Java Class option.
Right click on it; select the New->Java Class option.
Enter the class name in the dialog-box and click on the OK button.
Enter the class name in the dialog-box and click on the OK button.
It will open the Editor window with the class declaration.
It will open the Editor window with the class declaration.
We will now see how to run a Java application. Follow these steps and see how it runs −
Let us write a simple code, which will print a message on the console. Enter the following code in the Editor window −
Let us write a simple code, which will print a message on the console. Enter the following code in the Editor window −
public class HelloWorld { 
   public static void main(String[] args) { 
      System.out.println("Hello, World !!!"); 
   } 
}
Go to the Run menu and select the Run option.
Go to the Run menu and select the Run option.
Select the Class name and click on Run.
Select the Class name and click on Run.
If there are no compilation errors, then it will show output at the bottom of the window.
If there are no compilation errors, then it will show output at the bottom of the window.
 Print
 Add Notes
 Bookmark this page