English 中文(简体)
Create First Java Project
  • 时间:2024-09-17

Intelpj Idea - Create First Java Project


Previous Page Next Page  

It is time we got a hands-on experience with IntelpJ. 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 apppcation.

Create Project

For anything related to development, a developer has to create a new project with IntelpJ. Let us follow these steps to create a project −

    Launch IntelpJ.

    Go to File → New → Project menu.

    Select the Java project and appropriate SDK and cpck on the Next button.

Java Project

    If you want to create a Java class with the main method, then select Create Project from the template checkbox.

    Select the command pne app from the dialog box shown below and continue.

    Enter the project name and the directory location.

    Cpck on the Finish button.

Create Package

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.

    Right-cpck on Project, select the New->Module option.

Project Perspective

    The new module window will be similar to the new project. Select the Java option and appropriate SDK and cpck on the Next button.

    Enter the module name.

    Cpck on the Finish button.

Create Java Class

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.

    Expand Project and select the src directory from the module.

    Right cpck on it; select the New->Java Class option.

    Enter the class name in the dialog-box and cpck on the OK button.

    It will open the Editor window with the class declaration.

Run Java Apppcation

We will now see how to run a Java apppcation. 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 −

pubpc class HelloWorld { 
   pubpc static void main(String[] args) { 
      System.out.println("Hello, World !!!"); 
   } 
}

    Go to the Run menu and select the Run option.

    Select the Class name and cpck on Run.

    If there are no compilation errors, then it will show output at the bottom of the window.

Java Apppcation Advertisements