First program "Hello world"
Completion requirements
For a quick start and to get to know the integrated development environment (IDE), developers traditionally program the output of "hello world" at the beginning:
- Start IntelliJ IDEA
- Choose "Create New Project"
- Choose "Java" as type of project
- Select "Java" as the project type and - if you have not already done so - the Project SDK.
- Select "Create project from template" and choose "Java Hello World"
- Select "Project name" and "Project location"
- After finishing the File "Main.java" is generated with the class "Main". In Java the file name and the one only class defined in it must be the same:
1 public class Main { 2 3 public static void main(String[] args) { 4 System.out.println("Hello World!"); 5 } 6 }
Listing of file Main.java
The method main()(line 3) always marks the starting point of the program.
- The program can be started either by selecting
- "Run" => "Run 'Main'" (Shift + F10 or click the green arrow)
- "Run" => "Debug 'Main'" => "Start debugging" (Shift +F9 or click the green bug)
Now the console window "Run" shows:
"C:\Program Files\Java\jdk1.8.0_202\bin\java.exe" ...
Hello World!
Process finished with exit code 0
Last modified: Monday, 6 May 2019, 9:46 AM