Introduction to Java
Java is one of the most widely used programming languages in the world. It runs banking systems, Android apps, large websites, big-data tools and countless business applications. It's known for being reliable, fast, strongly typed and backed by an enormous ecosystem of libraries — and it keeps evolving, with a new version every six months.
A first look
void main() { System.out.println("Hello, Java!"); }
Hello, Java!
That's a complete Java program. Save it as Main.java, run java Main.java, and it prints a greeting. Lesson 3 explains every part — and the longer, traditional form you'll see in most existing code.
What makes Java Java
- Write once, run anywhere. Java code is compiled to bytecode, which runs on the Java Virtual Machine (JVM). The same compiled program runs on Windows, macOS and Linux.
- Statically typed. Every variable has a type that's checked before the program runs, so many mistakes are caught by the compiler instead of by your users.
- Object-oriented. Programs are built from classes and objects that bundle data with behaviour — though modern Java also embraces records, lambdas and functional-style streams.
- Automatic memory management. A garbage collector frees memory you no longer use.
- Huge standard library and ecosystem. Collections, networking, dates, concurrency and much more are built in, and tools like Maven, Gradle, Spring and JUnit cover almost every need.
How Java runs
Main.java ──javac──► Main.class (bytecode) ──java (JVM)──► running program
source code portable just-in-time compiled
to fast machine code
The javac compiler turns source code into bytecode. The JVM loads the bytecode and, as the program runs, compiles the busiest parts to native machine code. For single-file programs, java Main.java does both steps for you.
What is Java used for?
| Area | Examples |
|---|---|
| Back-end services | Web APIs and microservices with Spring Boot, Quarkus or Micronaut |
| Enterprise systems | Banking, insurance, retail, government |
| Android | Android apps (alongside Kotlin, which also runs on the JVM) |
| Big data | Hadoop, Kafka, Elasticsearch, Spark (Scala/JVM) |
| Tools and games | IntelliJ IDEA, Minecraft (Java Edition) |
Java versions
A new Java version is released every March and September. Every two years one becomes a long-term support (LTS) release that companies standardise on: Java 17 (2021), Java 21 (2023) and Java 25 (2025). This course uses Java 25 and points out features that older versions lack, since you'll meet older code at work.
Java and JavaScript
Despite the name, Java and JavaScript are unrelated languages. JavaScript runs in web browsers and is dynamically typed; Java is compiled, statically typed, and mostly runs on servers and devices. The similar name was a 1990s marketing decision.
How this course works
Every example in this course was compiled and run with a real Java 25 JDK, and the output shown beneath it is the actual output. The Try it yourself editors let you edit code and copy it to run on your own machine — lesson 2 shows how to set that up in a few minutes.
Try it yourself
My name is Sam. I am learning Java.