Fundamentals 36 min read

Understanding the Java Platform: JVM, JRE, JDK, Core Language Features and Common Java Concepts

This article provides a comprehensive overview of Java fundamentals, covering the relationship between JVM, JRE and JDK, the execution model, bytecode advantages, Java 8 language enhancements, core OOP principles, exception handling, reference types, and practical code examples for developers.

Wukong Talks Architecture
Wukong Talks Architecture
Wukong Talks Architecture
Understanding the Java Platform: JVM, JRE, JDK, Core Language Features and Common Java Concepts

Java Platform Overview

Java is an object‑oriented language known for its cross‑platform capability (Write Once, Run Anywhere) and automatic memory management via garbage collection.

JVM, JRE, JDK Relationship

JVM (Java Virtual Machine) executes Java bytecode on any platform.

JRE (Java Runtime Environment) bundles the JVM and core class libraries such as java.lang .

JDK (Java Development Kit) provides development tools (javac, jar, etc.) and includes a JRE, so installing the JDK eliminates the need for a separate JRE.

Is Java Interpreted?

Source code is first compiled to bytecode by javac . At runtime the JVM’s interpreter can execute bytecode, but most modern JVMs (e.g., HotSpot) use a Just‑In‑Time ( JIT ) compiler to translate hot code paths into native machine code.

Benefits of Bytecode

Bytecode is platform‑independent, enabling the same .class files to run on any operating system with a compatible JVM, which is the foundation of Java’s portability.

Key Java 8 Features

Default methods in interfaces

Lambda expressions and functional interfaces

Stream API for functional collection processing

Method references

New date‑time API

Optional to avoid NullPointerException

New tools such as Nashorn engine and jdeps

Common Language Topics

Constructors can be overloaded but not overridden.

wait() (from Object ) releases the monitor; sleep() (from Thread ) does not.

& is a bitwise AND; && is a short‑circuit logical AND.

Primitive types vs. wrapper classes (e.g., int vs. Integer ) and caching of values between –128 and 127.

Usage of this and super for member access and constructor chaining.

Member vs. Local Variables

Member variables belong to the object and reside on the heap; local variables exist on the stack and have no default values.

Dynamic Proxy

Implemented via reflection, dynamic proxies enable AOP, RPC wrappers, and other cross‑cutting concerns.

int vs. Integer

Primitive int holds a value; Integer is an object wrapper with caching for small values. Equality using == compares references for objects, while equals() compares logical content.

Object‑Oriented Fundamentals

Four OOP pillars – abstraction, encapsulation, inheritance, and polymorphism – are explained with examples of method overloading (compile‑time polymorphism) and overriding (runtime polymorphism).

Equals and hashCode

When equals() is overridden, hashCode() must also be overridden to maintain the contract required by hash‑based collections such as HashMap and HashSet .

SOLID Principles

Single Responsibility (SRP)

Open‑Closed (OCP)

Liskov Substitution (LSP)

Interface Segregation (ISP)

Dependency Inversion (DIP)

Exception vs. Error

Both inherit from Throwable . Exception represents recoverable conditions (checked and unchecked), while Error denotes serious JVM problems that applications should not catch.

final, finally, finalize

final can modify classes, methods, or variables.

finally block always executes after a try / catch , even when a return occurs.

finalize() is a method called by the garbage collector before object reclamation.

Reference Types

Strong, soft, weak, and phantom (virtual) references differ in reachability and garbage‑collection behavior; soft references are useful for memory‑sensitive caches, weak references for structures like ThreadLocalMap , and phantom references for cleanup notifications.

String, StringBuilder, StringBuffer

String is immutable and thread‑safe. StringBuilder offers mutable, non‑synchronized operations for single‑threaded use, while StringBuffer adds synchronization for multi‑threaded scenarios.

HashMap with String Keys

Strings are immutable and cache their hashCode , making them efficient keys for HashMap .

Interface vs. Abstract Class

Both cannot be instantiated. Interfaces define contracts (default and static methods since Java 8), while abstract classes can provide reusable implementation. Prefer interfaces for behavior modeling; use abstract classes when shared code is needed.

Value vs. Reference Passing

Java always uses pass‑by‑value; for objects the value passed is the reference, allowing the method to modify the object's state but not reassign the caller’s variable.

Basic and Object Data Types

Primitive types ( byte, short, int, long, float, double, char, boolean ) store raw values, whereas reference types (classes, interfaces, arrays) store object references.

public static void main(String[] args) {
    int num1 = 10;
    int num2 = 20;
    swap(num1, num2);
    System.out.println("num1 = " + num1);
    System.out.println("num2 = " + num2);
}

public static void swap(int a, int b) {
    int temp = a;
    a = b;
    b = temp;
    System.out.println("a = " + a);
    System.out.println("b = " + b);
}
public static void main(String[] args) {
    int[] arr = {1, 2, 3, 4, 5};
    System.out.println(arr[0]);
    change(arr);
    System.out.println(arr[0]);
}

public static void change(int[] array) {
    // set first element to 0
    array[0] = 0;
}
JavaJVMJDKString()oopExceptionReference Types
Wukong Talks Architecture
Written by

Wukong Talks Architecture

Explaining distributed systems and architecture through stories. Author of the "JVM Performance Tuning in Practice" column, open-source author of "Spring Cloud in Practice PassJava", and independently developed a PMP practice quiz mini-program.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.