![]() | Session 1 | ![]() |
First program
Once the environment is set up, write your first Java program - the traditional Hello World. The purpose of this program is to type the sentence Hello, World! on the monitor.
Step 1. Watch the video:
Step 2. Launch IntelliJ and start a new project. The wizard will ask you for a few names:



Step 3. Type the following source codes - a text file that contains instructions written in a high level language Java. The source code cannot be executed (made to run) by a processor without some additional steps (translation into bytecode).
The following source code defines a class called "HelloWorld". DO NOT COPY the code because your mind and hands need time to get used to a new programming language!

PS! Pay attention:
- Java is case-sensitive;
- the file name must be the same as the class name;
- punctuation: commas (,), dots (.), quotes ("), parentheses [({
- in classes, methods, and other flow-control structures, code is always enclosed in paired curly braces
{ }; - in Java, each code statement must end with a semicolon
;; but do not use semicolons after method and class declarations that follow with curly braces; - the highlighted "key words" - IntelliJ does it to make it easier for you to read your code.
Step 3. Compile/build the project and run the program (use the top menu):

PS! Pay attention to:
- a Java source file must have the extension of ".java";
- a compiled source code is a Java bytecode with extension of ".class".
Question:
Check the folder with your source code. Has a new file with extension of .class been added?
Keep the code:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
![]() | Session 1 | ![]() |

