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:

  1. Start IntelliJ IDEA
  2. Choose "Create New Project"
  3. Choose "Java" as type of project
  4. Select "Java" as the project type and - if you have not already done so - the Project SDK.
  5. Select "Create project from template" and choose "Java Hello World"
  6. Select "Project name" and "Project location"
  7. 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.


  1. 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