Java #

Java is one of the most influential programming languages ever created. Born in the mid-1990s with the promise of “write once, run anywhere”, Java has lived up to that claim for nearly three decades — surviving wave after wave of new languages and staying relevant through the cloud, mobile, and microservices eras. That’s no accident. Deliberate design decisions, a mature ecosystem, and a massive community all sit behind that resilience. This documentation covers Java from the ground up — not just syntax, but how Java thinks, how its runtime works, and why choices that look odd on the surface actually have solid reasoning behind them.

What Is Java? #

Java is an object-oriented programming language that runs on a virtual platform called the Java Virtual Machine (JVM). What made Java unique among the languages of its era is the clear separation between source code, compiled code, and the environment where that code runs. You write Java code, and the compiler turns it into bytecode — a binary format that isn’t native machine code, but also isn’t human-readable text. The JVM executes this bytecode, and the JVM is available for nearly every relevant operating system and processor architecture today.

The result: the same Java program can run on Linux, Windows, macOS, even on ARM chips without recompiling. In the 1990s, when platform fragmentation was a developer’s worst nightmare, this was a revolution.

Java was shaped by many earlier languages. Its syntax and type system borrow heavily from C++, while discarding the complexity considered dangerous — no pointer arithmetic, no ambiguous multiple inheritance, no manual memory management. The pure object concept comes from Smalltalk. The idea of portability and a virtual platform was inspired by Pascal and the UCSD p-System. The result is a language that feels familiar to C++ programmers but is far safer and more consistent.

flowchart LR
    A["Source Code\n(.java)"] -->|javac| B["Bytecode\n(.class)"]
    B -->|JVM Linux| C["Program runs\non Linux"]
    B -->|JVM Windows| D["Program runs\non Windows"]
    B -->|JVM macOS| E["Program runs\non macOS"]
    B -->|JVM ARM| F["Program runs\non ARM / Android"]

This “write once, run anywhere” philosophy isn’t just a marketing slogan. It reflects a consistent architectural decision: Java deliberately chooses a thicker abstraction layer over the hardware in exchange for portability. That tradeoff makes Java sometimes slower than C++ for compute-intensive work, but far more productive for business applications, servers, and enterprise systems whose main needs aren’t raw performance but reliability and maintainability.


History and Origins #

Java was born at Sun Microsystems in the early 1990s, initiated by James Gosling — a Canadian computer scientist later known as the “Father of Java”. The project was originally called the Green Project, and its initial goal wasn’t to build a server or web language — it was to create software for consumer electronics: set-top boxes, remote controls, interactive televisions.

The language developed first was named Oak (after the oak tree growing outside Gosling’s office). But the name Oak was already used by another company and couldn’t be trademarked. Java was chosen as the replacement — inspired by Java coffee, a brew popular among programmers. The first public release was JDK 1.0 on January 23, 1996.

Its launch timing coincided perfectly with the explosion of the World Wide Web. Java offered something that didn’t exist before: applets — small programs embedded in web pages that ran in a visitor’s browser without installation. Netscape Navigator 2.0, the most popular browser at the time, announced Java applet support. Overnight, Java became a sensation.

flowchart TD
    A["1991 — Green Project starts\nJames Gosling & team at Sun Microsystems"] --> B["1992 — First prototype\nLanguage named Oak"]
    B --> C["1994 — Pivot to the Web\nTarget: browsers and the internet"]
    C --> D["1995 — Java 1.0 announced\nNetscape adopts Java Applet"]
    D --> E["1996 — JDK 1.0 released\nJanuary 23, 1996"]
    E --> F["1998 — Java 2 (J2SE 1.2)\nSwing, Collections Framework"]
    F --> G["2004 — Java 5\nGenerics, Annotations, Enums, Autoboxing"]
    G --> H["2014 — Java 8\nLambda, Stream API, Optional"]
    H --> I["2017 — Java 9\nModule System (Project Jigsaw)"]
    I --> J["2018 — Six-month release cycle\nJava 11 LTS, 17 LTS, 21 LTS, ..."]

But Java’s journey wasn’t always smooth. Applets were gradually abandoned due to security and performance concerns. Sun Microsystems was acquired by Oracle Corporation in 2010 in a $7.4 billion deal. The acquisition brought controversy — Oracle sued Google over the use of Java APIs in Android, a legal battle that dragged on for years before being settled by the US Supreme Court. On the technical side, though, Oracle actually accelerated Java’s evolution by adopting a six-month release cycle starting with Java 9 (2017) — a change needed to keep Java relevant in a fast-moving ecosystem.


Where Is Java Used? #

Java isn’t an academic language. It’s everywhere in industry, often in places you can’t see but that are the most critical.

Enterprise Applications and Backend Servers #

This is Java’s natural habitat. Most large-scale enterprise applications — banking, insurance, logistics, telecommunications — are built on Java. Frameworks like Spring Boot, Quarkus, and Micronaut make Java the top choice for REST APIs, microservices, and systems that need high reliability. Major banks around the world run their core banking systems on Java, not because it’s trendy, but because Java has proven stable for decades.

Android #

Historically, Android development used Java as its primary language. Although Google now recommends Kotlin, the entire Android SDK and framework are built on the Java platform (JVM). Understanding Java means understanding the foundation beneath every Android app — how the lifecycle works, how memory is managed, how threading and concurrency are implemented.

Big Data and Data Engineering #

The modern big data ecosystem relies heavily on the JVM. Apache Hadoop, Apache Spark, Apache Kafka, Apache Flink, Elasticsearch — all are built in Java or Scala (which also runs on the JVM). If you work in data engineering, knowing Java or Scala is a practical requirement, not a choice.

Developer Tools and IDEs #

Almost every popular IDE is written in Java: IntelliJ IDEA, Eclipse, NetBeans, Android Studio. Build tools like Maven and Gradle are also JVM-based. That’s no coincidence — the JVM provides the portability that tools running across many operating systems need.

flowchart TD
    Java["Java & JVM Ecosystem"] --> Enterprise["Enterprise Backend\nSpring Boot, Quarkus\nCore Banking, ERP"]
    Java --> Android["Mobile - Android\nAndroid SDK\nAndroid Studio"]
    Java --> BigData["Big Data & Streaming\nKafka, Spark, Hadoop\nFlink, Elasticsearch"]
    Java --> Tools["Developer Tools\nIntelliJ, Eclipse\nMaven, Gradle"]
    Java --> Embedded["Embedded & IoT\nJava ME\nSmart Card"]
    Java --> Cloud["Cloud Native\nGCP, AWS Lambda\nKubernetes Operators"]

Java Virtual Machine (JVM) #

The JVM is the heart of the entire Java ecosystem. Understanding the JVM isn’t just academic knowledge — it directly affects how you write efficient code, diagnose performance issues, and debug memory problems.

How the JVM Works #

When you run a Java program, the sequence of events goes like this:

  1. The javac compiler converts .java source code into .class bytecode
  2. The JVM loads the .class file through the Class Loader
  3. The Bytecode Verifier checks that the bytecode is valid and doesn’t violate security rules
  4. The Interpreter executes the bytecode line by line
  5. The JIT Compiler (Just-In-Time) identifies hot paths — code executed frequently — and compiles them into native machine code for higher performance
sequenceDiagram
    participant Dev as Developer
    participant javac as Java Compiler
    participant CL as Class Loader
    participant BV as Bytecode Verifier
    participant JIT as JIT Compiler
    participant CPU as CPU / Hardware

    Dev->>javac: javac Main.java
    javac-->>Dev: Main.class (bytecode)
    Dev->>CL: java Main
    CL->>BV: Verify bytecode
    BV-->>CL: Bytecode valid
    CL->>JIT: Execution
    JIT->>CPU: Compile hot path → native code
    CPU-->>Dev: Program output

Garbage Collection #

One of the JVM’s most important features is the Garbage Collector (GC) — an automatic memory management system. You never call free() or delete like in C/C++. The JVM automatically detects objects that are no longer referenced and frees their memory.

Modern JVMs offer several GC algorithms, each with different tradeoffs:

GC AlgorithmCharacteristicsBest For
Serial GCSingle-thread, high pause timesSmall applications, small heaps
Parallel GCMulti-thread, high throughputBatch processing, compute-intensive work
G1 GCBalanced pause time and throughputDefault since Java 9, general-purpose applications
ZGCVery low pause times (< 1ms)Low-latency applications, large heaps
ShenandoahConcurrent GC, low pausesZGC alternative, developed by Red Hat
An “automatic” GC doesn’t mean you can ignore memory management. Memory leaks in Java are still possible — for example, keeping references to objects in a static collection that never gets cleaned up. “Automatic” here means the JVM executes the memory freeing, not that you don’t need to think about object lifetimes at all.

The JVM Is Not Just for Java #

One of the best design decisions in JVM history was separating the platform from the language. The JVM only cares about bytecode — it doesn’t care what language produced that bytecode. This opened the door for many languages to leverage the mature JVM ecosystem:

LanguageDescription
KotlinModern language from JetBrains, fully interoperable with Java, official Android language
ScalaHybrid functional-OOP language, popular in big data (Spark)
GroovyDynamic language, used in Gradle and testing (Spock)
ClojureModern Lisp on the JVM, focused on concurrency and immutability
JythonPython implementation on the JVM
JRubyRuby implementation on the JVM

Java Development Kit (JDK) #

The JDK is the package you install to develop Java programs. It’s not just a runtime — it includes every tool you need during development.

JDK Components #

JDK (Java Development Kit)
  ├── JRE (Java Runtime Environment)
  │   ├── JVM (Java Virtual Machine)
  │   └── Java Class Library (rt.jar / modules)
  ├── javac          ← compiler
  ├── java           ← launcher
  ├── javadoc        ← documentation generator
  ├── jar            ← archive tool
  ├── jdb            ← debugger
  ├── jshell         ← REPL (since Java 9)
  ├── jlink          ← custom runtime image builder
  ├── jmap           ← heap dump tool
  └── jstack         ← thread dump tool

LTS Versions and Release Cycle #

Since Java 9 (2017), Java is released every six months. Not every version gets long-term support — only LTS (Long-Term Support) versions receive security patches and bug fixes for years.

VersionReleaseStatusKey Notes
Java 8March 2014LTS (extended)Lambda, Stream API, Optional — still widely used
Java 11September 2018LTSNew HTTP Client, var in lambdas
Java 17September 2021LTSSealed classes, pattern matching for instanceof
Java 21September 2023LTSVirtual threads (Project Loom), record patterns
Java 25September 2025LTS (upcoming)
For new projects in 2024–2025, Java 21 is the right choice. It’s the latest LTS with the most modern features, including virtual threads — which fundamentally change how concurrent code is written. For existing projects, Java 17 is a safe upgrade target before moving to 21.

JDK Distributions #

Because Java is an open source platform (OpenJDK), various vendors provide their own JDK distributions. They all follow the same specifications (JSR, JEP), but each has different optimizations and support policies:

DistributionVendorNotes
OpenJDKOracle / communityReference implementation, open source
Oracle JDKOracleCommercial license for production, free for development
Eclipse TemurinAdoptiumMost popular community distribution, license-free
Amazon CorrettoAmazonOptimized for AWS, free and open source
Azul ZuluAzul SystemsAvailable for many platforms, including exotic ones
GraalVMOracle / communityFaster JIT, can compile to native binaries
Microsoft Build of OpenJDKMicrosoftOptimized for Azure, good Windows support
Red Hat Build of OpenJDKRed HatOptimized for RHEL/Fedora/OpenShift

For most projects, Eclipse Temurin (from Adoptium) or Amazon Corretto are safe choices — free, no production license restrictions, and long-term support.


Characteristics of the Java Language #

Understanding why Java was designed a certain way matters more than memorizing its syntax. Here are the core characteristics that shape how Java thinks.

Strongly and Statically Typed #

Java is a strongly typed language — every variable has a clear type, and types can’t change implicitly. This differs from JavaScript or Python, which are more permissive. In Java, you have to be explicit:

// Java: types must be declared
int count = 42;
String name = "Budi";
double price = 15_000_000.0;

// Since Java 10: var for local variable type inference
var items = new ArrayList<String>(); // the compiler knows this is ArrayList<String>

// ANTI-PATTERN that's impossible in Java:
// count = "forty two"; // compile error

Static typing means types are checked at compile time, not runtime. Type bugs are caught before the program runs — a huge advantage for large codebases where runtime errors are far more expensive.

Object-Oriented #

Java is a consistently OOP language — almost everything is an object. There are a few exceptions for primitive types (int, long, double, boolean, etc.) for performance reasons, but every primitive has its wrapper class (Integer, Long, Double, Boolean).

// Primitives: stored directly on the stack, not as objects
int number = 42;
double pi = 3.14159;

// Wrapper classes: needed when you need an object (generics, collections)
Integer numberObj = Integer.valueOf(42);
List<Integer> list = new ArrayList<>(); // can't do List<int>

// Autoboxing: Java automatically converts between primitives and wrappers
list.add(100);         // int → Integer automatically
int value = list.get(0); // Integer → int automatically

Platform Independence #

The “write once, run anywhere” principle is implemented through bytecode and the JVM. Java bytecode is platform-neutral — it’s not instructions for x86, not for ARM, but instructions for an abstract virtual machine that the JVM then translates into native machine code on the target platform.

Memory Safety #

Java eliminates the most dangerous categories of bugs in C/C++:

  • No pointer arithmetic — you can’t write to arbitrary memory addresses
  • Array bounds checking — out-of-bounds index access always raises an exception, never undefined behavior
  • Garbage collection — memory is freed automatically, eliminating use-after-free and double-free
  • Null safety (partial) — although NullPointerException still exists, modern Java keeps getting better at detecting issues via annotations and Optional
// ANTI-PATTERN: code that can NPE
String name = getName(); // could return null
System.out.println(name.toUpperCase()); // NullPointerException if null!

// CORRECT: use Optional for values that may be null
Optional<String> name = getOptionalName();
name.ifPresent(n -> System.out.println(n.toUpperCase()));

// Or with map
String result = name.map(String::toUpperCase).orElse("(none)");

Ecosystem and Community #

Java isn’t just a language — it’s an ecosystem. The maturity of this ecosystem is one of the main reasons Java remains highly relevant after nearly three decades.

Maven Central Repository #

Maven Central is the world’s largest Java library repository, with hundreds of thousands of artifacts available for free. Need a library for JSON parsing? There’s Jackson and Gson. Need an HTTP client? There’s OkHttp and Apache HttpClient. Need dependency injection? There’s Spring and Guice. There’s almost always a mature, battle-tested library for whatever you need.

Build Tools #

ToolDescription
MavenXML-based build tool, convention over configuration, the most widely used in enterprise
GradleBuild tool based on Groovy/Kotlin DSL, more flexible and faster than Maven
AntLegacy XML-based build tool, rarely used in new projects

Major Frameworks #

FrameworkDomainDescription
Spring BootWeb, microservices, enterpriseThe most popular framework in the Java ecosystem
QuarkusCloud native, microservicesOptimized for Kubernetes and GraalVM native images
MicronautMicroservicesCompile-time DI, fast startup
HibernateORMDe facto standard for database access in Java
JUnitTestingThe most popular testing framework in Java

What You’ll Learn in This Documentation #

This documentation is structured from foundations to advanced topics, following a flow that builds understanding gradually — not a random pile of references.

flowchart TD
    A["Basics\nSyntax, Data Types, Variables\nControl Flow, Functions, Classes"] --> B["Advanced\nConcurrency, I/O, Stream\nUnit Test, Networking"]
    B --> C["Other Topics\nSQL & NoSQL Databases\nMessage Broker, Cache\nFramework & Library"]
    C --> D["Standard Library\nStrings, IO, Math\nand other modules"]

The Basics section covers the foundations: Java syntax, the type system, variables, operators, control flow (if-else, switch, loops), functions (methods), classes and OOP, interfaces, exception handling, up to the collection framework (List, Map) and build tools.

The Advanced section moves into the topics that separate an ordinary Java programmer from a skilled one: multi-threading and concurrency, blocking vs non-blocking I/O, socket programming, web servers, unit testing with JUnit, mocking with Mockito, and the Stream API that changes how you write iterative code.

The Other Topics section is practical: integrating Java with technologies you’ll frequently meet in the real world — relational databases (MySQL, PostgreSQL, Oracle, MSSQL), NoSQL databases (MongoDB, Elasticsearch), message brokers (Kafka, RabbitMQ, Amazon SQS), caches (Redis, Memcached), and popular frameworks (Spring Boot, Quarkus).

The Standard Library section covers Java’s built-in modules you’ll use often: string manipulation, I/O operations, math functions, and more.


Summary #

  • Java is a platform, not just a language — Java code compiles to bytecode that runs on the JVM, not directly to machine code. This is the foundation of “write once, run anywhere”.
  • The JVM is a sophisticated virtual machine — it’s not just an interpreter. The JIT compiler, garbage collector, and integrated profilers give the JVM high performance for production workloads.
  • Choose the right JDK — for new projects, use Java 21 LTS. For JDK distributions, Eclipse Temurin or Amazon Corretto are safe, license-free choices.
  • Static typing is an asset, not a burden — type bugs are caught at compile time, not runtime. In large codebases, this saves a lot of debugging time.
  • The ecosystem is Java’s greatest strength — hundreds of thousands of libraries on Maven Central, mature frameworks, and a huge community mean a tested solution already exists for almost every problem.
  • Modern Java isn’t old Java — Java 8 brought lambdas and the Stream API. Java 17 brought sealed classes and pattern matching. Java 21 brought virtual threads. Java keeps evolving — don’t judge it by outdated impressions.
  • An automatic GC doesn’t mean you’re free of memory issues — memory leaks can still happen if you hold unnecessary references. Understand how the GC works to write efficient code.

Next: Installation →
About | Author | Content Scope | Editorial Policy | Privacy Policy | Disclaimer | Contact