JavaRush /Java Blog /Random EN /Creating and launching your first Java application (part ...
Ve4niY
Level 14

Creating and launching your first Java application (part 1)

Published in the Random EN group
To get an idea of ​​how IntelliJ IDEA can help you develop and run Java applications, we suggest you create and run a simple "Hello, World" example in this program. This way you can learn about the basic IDE features without having to go into the details of the code. Step-by-step instructions will help you not to get confused in the intricacies of launching and configuring the program. Creating and launching your first Java application (part 1) - 1

Before starting work

To create Java applications, you will need the Java Development Kit ( JDK ). If the program is not already installed, it can be downloaded and installed from Oracle.com . Installation instructions can also be found there.

Creating a Project

Creating any application in IntelliJ IDEA begins with creating a project (you can find out why a project is needed in IntelliJ IDEA Help, by clicking the Project link ), so our first step is to create a “Hello, World” project. This project will contain a Java module for our Java application.
  1. If no project is currently open, click the Create New Project button on the Welcome screen. Otherwise, select New Project from the File menu. This will open the New Project Wizard.

  2. In the left pane, select Java Module .

  3. On the right side of the page, in the Project name field , enter the name of the project: HelloWorld.

    Creating and launching your first Java application (part 1) - 2
  4. If you have never configured a JDK in IntelliJ IDEA before (in which case the Project SDK field is <None> ), you need to do it now.

    Instead of <None>, click New and select JDK from the submenu .

    In the Select Home Directory for JDK window , select the directory where the JDK was installed and click OK .

    Creating and launching your first Java application (part 1) - 3

    The JDK version you selected will appear in the Project SDK field .

    Creating and launching your first Java application (part 1) - 4

    Click Next .

    Please note that the specified JDK version will be associated by default with all projects and Java modules that will be created in the future.

  5. On the next page, you select a wizard to indicate additional technologies that will be supported in our module.

    Creating and launching your first Java application (part 1) - 5

    Since our application will be a "good old Java application", we don't need any of these technologies. So just click the Finish button .

    Wait while IntelliJ IDEA creates the necessary project structures. When this process is complete, you can see the structure of your new project in the Project window .

Studying the project structure

Let's take a look at the project structure. Creating and launching your first Java application (part 1) - 6In the project tree we see two top-level directories:
  • HelloWorld . This is the node containing your Java module. The .idea folders and files inside the HelloWorld.iml directory are used to store your project's configuration data and modules respectively. The SRC folders contain the source code.

  • External Libraries (external libraries). This is a category that represents all the "external" resources needed for your project. Currently this category contains .jar files from our chosen JDK.
Of all the folders mentioned, we will only need SRC in this example. (For more information on tool windows in general and the Project window in particular, see IntelliJ IDEA Tool Windows and Project Tool Window in IntelliJ IDEA Help)

Creating a package

Now we're going to create a package for the class HelloWorld (We'll create this class a little later.) Let's call this package com.example.helloworld.
  1. In the Project tool window, select the SRC folder and press ALT+INSERT. (Alternatively, you can select File -> New , or New from the context menu for the SRC folder).

  2. From the New menu , select Package . (you can use the up and down arrows to navigate through the menu, ENTER to select the highlighted item)

    Creating and launching your first Java application (part 1) - 7
  3. In the New Package window that opens , enter the package name (com.example.helloworld). Click OK (or ENTER key).

    Creating and launching your first Java application (part 1) - 8

    The new package will appear in the Project window .

    Creating and launching your first Java application (part 1) - 9

Creating a class

  1. Press ALT+INSERT. In the New window , from the list of available actions with the com.example.helloworld package selected, select Java Class and press Enter.

    Creating and launching your first Java application (part 1) - 10
  2. In the Create New Class window that appears , in the Name field , enter the name HelloWorld. In the Kind field , leave the Class type and press Enter to confirm the creation of the class.

    Creating and launching your first Java application (part 1) - 11

    The created HelloWorld class appears in the project structure:

    Creating and launching your first Java application (part 1) - 12

    At this point all preparations are completed. The process of writing our first code will be discussed in the second part of the article.

Source article: Creating and running your first Java application Translated and voiced by: Ve4niY Creating and running your first Java application (part 2)
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION