Java Essentials · Месяц 1
Introduction to Java & the JVM
Goal: understand what Java is, how a Java program runs, and write and run your first program. Duration: 90 min · You need: a laptop with internet
1. Why Java?
Java is one of the most used programming languages in the world. Banks (Kapital Bank, ABB, PASHA), payment systems, airlines, e-commerce and big companies like Google, Amazon and Netflix run huge backend systems on Java.
Java is:
- Object-oriented: we model the real world with objects (a
Customer, anOrder, aPayment). - Strongly typed: the compiler checks types before the program runs, so many bugs are caught early.
- Platform independent: the same compiled program runs on Windows, macOS and Linux.
- Huge ecosystem: Spring Boot, Hibernate, Kafka clients, thousands of libraries.
2. JDK, JRE and JVM
| Term | What it is | Who needs it |
|---|---|---|
| JVM (Java Virtual Machine) | Runs compiled Java bytecode | Every machine that runs Java |
| JRE (Java Runtime Environment) | JVM + standard libraries | Users who only run programs |
| JDK (Java Development Kit) | JRE + compiler (javac) + tools |
Developers (us) |
How a Java program runs:
Hello.java --javac--> Hello.class (bytecode) --java (JVM)--> runs on any OS
This is the famous "write once, run anywhere": you compile once to bytecode; the JVM on each operating system translates it to machine code.
3. Step by step: install your tools
Step 1: Install JDK 21
- Open https://adoptium.net and download Temurin 21 (LTS) for your OS.
- Install with default settings.
- Open a terminal (Windows:
cmd, macOS: Terminal) and check:
java -version
javac -version
You should see 21.x.x. If you see "command not found", restart the terminal or re-install with "Add to PATH" checked.
Step 2: Install IntelliJ IDEA
- Download IntelliJ IDEA Community Edition (free) from jetbrains.com.
- Install and open it.
- New Project → Language: Java → Build system: IntelliJ → JDK: 21 → Create.
4. Your first program
Create a class Hello inside src:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
Click the green ▶ next to main. You should see Hello, Java! in the console.
Line by line
| Code | Meaning |
|---|---|
public class Hello |
A class named Hello. The file must be called Hello.java. |
public static void main(String[] args) |
The entry point: the JVM starts here. |
System.out.println(...) |
Prints text and moves to a new line. |
; |
Every statement ends with a semicolon. |
{ } |
Curly braces group code into blocks. |
Run it from the terminal too
javac Hello.java # compile → creates Hello.class
java Hello # run (no .class extension!)
5. print vs println, comments
System.out.print("Hello "); // no new line
System.out.println("world"); // new line after
System.out.println(); // empty line
// single-line comment
/* multi-line
comment */
6. Common mistakes
- ❌ File name differs from class name (
hello.javavsclass Hello). Java is case-sensitive. - ❌ Missing semicolon
;. Read the compiler error: it shows the line number. - ❌ Writing
system.out.println: it must beSystemwith a capital S. - ❌ Running
java Hello.class: runjava Hello.
7. Exercises (in class)
- Print your name, city and favourite food on three lines.
- Print the same three values on one line using
print. - Print this shape:
*
***
*****
- Break the program on purpose (remove a
;, rename the class) and read the error messages.
8. Homework
Write a program AboutMe that prints a small "business card":
==========================
Name: Anar Alizada
Goal: Java Backend Developer
Start: 2026
==========================
9. Self-check
- What is the difference between the JDK and the JVM?
- What does
javacproduce? - Why can a compiled Java program run on any OS?
- What must the file containing
public class Paymentbe called?
Answers
- JDK is the full developer kit (compiler + tools + JRE); JVM is only the engine that runs bytecode.
- A
.classfile containing bytecode. - Because bytecode runs on the JVM, and there is a JVM for every OS.
Payment.java.