Skip to main contentLogo

Command Palette

Search for a command to run...

Understanding Java / From Code to JVM

Published on
Feb 13, 2025
Understanding Java / From Code to JVM

What is Java?

Java—like any programming language—has its own structure, syntax rules, and programming paradigm. The primary paradigm of Java is Object-Oriented Programming (OOP).

Java is a programming language derived from C. Therefore, its syntax is very similar to C:

  • Code blocks are organized as methods and enclosed with {}.
  • Variables must be declared before they are used.

Structurally, Java programs start with packages. In Java, a package represents a namespace mechanism. Inside packages are classes, and within classes there are methods, variables, constants, and other elements.


Java Compiler

When writing a Java program, the code is stored in .java files and compiled by a compiler.

The compiler performs the following functions:

  • Checks the source code for syntax correctness.
  • Generates bytecode from the code and outputs a .class file.

Bytecode is an intermediate instruction set intended for the Java Virtual Machine (JVM) rather than for the processor directly.

➡️ This approach enables Java to run across different platforms.


JVM (Java Virtual Machine)

The JVM reads and executes the bytecode contained in .class files.

  • It translates the bytecode into machine code tailored to the platform and executes it.
  • Because the JVM is implemented separately for each platform, Java supports the principle of "write once, run anywhere".
  • The JVM exists for Windows, Linux, and even mobile devices.

➡️ The JVM underpins Java’s portability and platform independence.


Garbage Collector

The Java platform performs memory management automatically.

  • When a new object is created, the JVM allocates space for it on the heap.
  • The Garbage Collector runs in the background, identifying objects that are no longer used and reclaiming their memory.

This is called implicit memory management, meaning developers do not need to write manual memory-freeing code.

➡️ This is one of Java’s key advantages in terms of performance and security.


JDK (Java Development Kit)

The JDK — Java Development Kit includes everything needed to write and run Java programs:

  • Compiler (javac) — converts source code to bytecode
  • Debugger, profiler, and other tools
  • Standard Java libraries — a collection of useful classes and methods
  • Java Runtime Environment (JRE)

📚 Learn more: Javadoc — Official Java API Documentation

➡️ For Java development, the JDK alone is sufficient.


JRE (Java Runtime Environment)

The JRE — Java Runtime Environment includes the following components required to run Java programs:

  • JVM
  • Standard libraries
  • Configuration and resources

The JRE is available for multiple platforms and can be distributed to end users.

➡️ The JDK is for developers, while the JRE is for users — the JRE is for running programs, and the JDK is for development purposes.

Thanks for reading.