Introduction to Java
Java is one of the most widely used programming languages in the world. It powers Android apps, enterprise backends, big-data pipelines, and financial systems. Its core promise — “Write Once, Run Anywhere” — means compiled bytecode runs on any device with a Java Virtual Machine (JVM).
History and Evolution
Java originated as a project called Oak in the early 1990s at Sun Microsystems, led by James Gosling. Renamed Java and released in 1995, it quickly became the language of the web applet era and later dominated enterprise server development.
Major milestones:
| Version | Year | Highlights |
|---|---|---|
| Java 1.0 | 1996 | Core language, AWT |
| Java 5 | 2004 | Generics, enums, annotations |
| Java 8 | 2014 | Lambda expressions, Stream API |
| Java 11 | 2018 | LTS — HTTP client, var keyword |
| Java 17 | 2021 | LTS — sealed classes, records |
| Java 21 | 2023 | LTS — virtual threads, pattern matching |
Oracle releases a new feature version every six months; LTS (Long-Term Support) releases are recommended for production.
Key Features of Java
- Platform Independence: Source compiles to bytecode (
.classfiles) executed by the JVM on Windows, Linux, macOS, or cloud containers. - Object-Oriented: Everything lives in a class. Inheritance, encapsulation, and polymorphism are built in.
- Robust and Secure: Strong typing, exception handling, and a security manager (where enabled) reduce runtime failures.
- Multi-threaded:
Thread,ExecutorService, and since Java 21, virtual threads simplify concurrent programming. - Rich API: Collections, I/O, networking, concurrency utilities, and the modern
java.timepackage cover most daily tasks. - Automatic Memory Management: The garbage collector reclaims unused objects; developers rarely call
free()manually.
How Java Works
Source (.java) → javac → Bytecode (.class) → JVM → Machine execution
The JVM also provides Just-In-Time (JIT) compilation, turning hot bytecode paths into native machine code for performance comparable to statically compiled languages.
Your First Java Program
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
Compile and run:
javac HelloWorld.java
java HelloWorld
# Output: Hello, Java!
Using a modern JDK, you can also run single-file programs without explicit compilation:
java HelloWorld.java
Variables, Types, and OOP Preview
public class UserDemo {
public static void main(String[] args) {
int id = 1;
String name = "Alice";
boolean active = true;
User user = new User(id, name, active);
System.out.println(user.greeting());
}
}
record User(int id, String name, boolean active) {
String greeting() {
return "Hello, " + name + "!";
}
}
Records (Java 16+) provide concise immutable data carriers — ideal for DTOs and domain models.
Java vs Other Languages
Java vs Python: Java is statically typed and compiled to bytecode; Python is dynamically typed and interpreted. Java excels in large, long-lived enterprise codebases; Python excels in scripting, data science, and rapid prototyping.
Java vs C#: Both target enterprise and share similar syntax. Java runs on the JVM and is the default for Android (with Kotlin). C# targets the .NET runtime and integrates tightly with Microsoft tooling.
Java vs JavaScript: JavaScript runs in browsers and (via Node.js) on servers with an event-driven model. Java is strongly typed, compiled, and preferred for high-throughput backend services.
Common Use Cases
| Domain | Example |
|---|---|
| Enterprise backends | Spring Boot REST APIs, microservices |
| Android | Native apps (often with Kotlin) |
| Big data | Apache Spark, Hadoop ecosystem |
| Financial services | Trading platforms, payment systems |
| Cloud | AWS Lambda (with custom runtime), Kubernetes workloads |
Setting Up Your Environment
- Install a JDK (Java Development Kit) — JDK 21 LTS is recommended.
- Set
JAVA_HOMEand add$JAVA_HOME/binto yourPATH. - Choose an IDE — IntelliJ IDEA Community, Eclipse, or VS Code with Java extensions.
- Verify:
java -versionandjavac -version.
See Installing Java and Java IDEs for step-by-step setup.
What Comes Next
This track covers language fundamentals, collections, concurrency, I/O, JVM internals, and modern features like virtual threads and the Stream API. Follow the pages in order to build from Hello World to production-ready Java development.
The Java Ecosystem
Beyond the language itself, Java developers rely on:
- Build tools — Maven and Gradle manage dependencies and compile steps.
- Frameworks — Spring Boot dominates enterprise backends; Quarkus and Micronaut target cloud-native workloads.
- Testing — JUnit 5 and Mockito are industry standards.
- Package repositories — Maven Central hosts millions of open-source libraries.
Installing the JDK
Download JDK 21 LTS from Adoptium or Oracle. Verify:
java -version
javac -version
Set JAVA_HOME to the JDK directory (not the JRE).
Maven Quick Start
mvn archetype:generate -DgroupId=com.example -DartifactId=demo \
-DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
cd demo
mvn package
java -jar target/demo-1.0-SNAPSHOT.jar
Why Learn Java in 2025?
- Massive job market in enterprise, finance, and Android (with Kotlin).
- Mature tooling, profiling, and monitoring ecosystem.
- Strong typing and decades of production hardening.
- Virtual threads (Java 21) make high-concurrency servers simpler than ever.