Java

On this page 7

Java is a general-purpose, statically typed, object-oriented programming language that compiles source code into platform-independent bytecode, which runs on the Java Virtual Machine (JVM). Among programming languages, it is best known for the principle of write once, run anywhere, automatic memory management and a very large ecosystem for server-side and enterprise software.

Java was released by Sun Microsystems in 1995 and has been stewarded by Oracle since 2010, with the reference implementation developed in the open as OpenJDK. The language evolves through a six-month feature release cadence, while selected versions receive long-term support for production use.

How Java code runs on the JVM

Java code runs in two stages. The javac compiler first translates .java source files into bytecode stored in .class files, usually packaged in JAR archives. The JVM then loads these classes, verifies the bytecode for safety and executes it, which allows the same compiled program to run on Windows, Linux, macOS and other systems with a compatible JVM.

Execution starts in an interpreter, but the HotSpot JVM profiles running code and hands frequently executed methods to a just-in-time (JIT) compiler. Its tiered design uses a fast compiler for quick startup and an optimizing compiler for hot code, applying inlining, escape analysis and other optimizations based on real runtime behavior.

Memory is managed by a garbage collector, so developers allocate objects without freeing them manually. The table below lists the main collectors in current JDK versions.

CollectorDesign goalTypical pause timesTypical use
G1Balanced throughput and latencyTens of millisecondsDefault for most server applications
ZGCVery low latency on large heapsUsually under a millisecondLatency-sensitive services
ShenandoahConcurrent compaction, low pausesLow millisecondsLow-latency workloads
ParallelMaximum throughputLonger stop-the-world pausesBatch processing
SerialSmall footprintVaries with heap sizeSmall containers and tools
Garbage collectors available in modern JDKs

Core language features

Java’s core features are static typing, class-based object orientation and a strict separation between primitives and objects. Every piece of code lives inside a class or interface, types are checked at compile time, and the language supports single class inheritance with multiple interface implementation.

Since Java 8, the language has added functional and data-oriented features at a steady pace: lambda expressions and streams, local type inference with var, records for immutable data carriers, sealed classes for restricted hierarchies, pattern matching in switch and instanceof, and virtual threads that make it practical to run hundreds of thousands of lightweight concurrent tasks.

VersionRelease yearNotable additions
Java 82014Lambdas, streams, new date and time API
Java 112018Standard HTTP client, var in lambdas
Java 172021Records, sealed classes, text blocks
Java 212023Virtual threads, pattern matching for switch
Java 252025Further language and runtime refinements
Long-term support versions of Java

Java compared with neighboring languages

Java is often compared with C#, its closest counterpart on .NET, with Kotlin and Scala, which also compile to JVM bytecode, and with dynamic languages such as Python. The comparison mostly concerns verbosity, runtime model and ecosystem rather than raw capability.

LanguageRuntimeTypingMain difference from Java
JavaJVMStatic, nominalReference point
KotlinJVM, also native and JavaScriptStatic with null safetyMore concise syntax, built-in null safety
ScalaJVMStatic, advanced type systemStrong functional programming focus
C#Common Language RuntimeStatic, nominalSimilar model on the .NET platform
PythonInterpreterDynamicFaster to write, slower to execute
C++Native codeStaticManual memory control, no garbage collector
Java and related programming languages

Because Kotlin, Scala and Java share the JVM, they can call each other’s libraries directly, which lets teams adopt a newer JVM language gradually without rewriting existing Java code.

Where Java is used and how to choose a JDK

Java dominates enterprise back-end development, including banking, insurance, telecommunications and e-commerce systems, typically built with frameworks such as Spring or Jakarta EE. It also powers large data tools such as Apache Kafka, Hadoop and Elasticsearch. Android applications have long been written in Java, although Android runs them on its own runtime rather than a standard JVM and Kotlin is now preferred there.

Developers install a JDK (Java Development Kit), which contains the compiler, the JVM and tools. Several vendors build JDKs from OpenJDK sources, and they differ mainly in support terms and licensing, not in language features.

Distribution typeCostTypical choice for
Community OpenJDK buildsFreeMost development and production use
Cloud vendor buildsFreeWorkloads running on that vendor’s cloud
Commercial supported JDKsPaid subscriptionOrganizations needing contractual support
Native image toolchainsFree and paid editionsFast-starting containers and command-line tools
Typical JDK distribution choices

Build tools such as Maven and Gradle manage dependencies from public repositories, and production teams usually standardize on one LTS version, upgrading every few years to stay within security support.

Limitations and common misconceptions

Java’s main weaknesses are verbosity, slower startup than native programs and a higher memory footprint caused by the JVM and its heap. Technologies such as class data sharing and ahead-of-time native images reduce startup time to milliseconds for serverless and container use, at the cost of longer builds and some restrictions on reflection.

  • Java is not JavaScript: the two languages share only part of a name and some C-style syntax.
  • Java is not inherently slow: JIT-compiled Java often approaches native performance for long-running services.
  • Garbage collection does not prevent memory leaks: objects still referenced from caches or static fields are never freed.
  • OpenJDK builds are free to use: licensing fees apply only to specific commercial distributions and support contracts.

In simple terms

Java is a language for writing software. Its special trick is a translator called the Java Virtual Machine. Programmers write their code once and turn it into a common in-between form. Any computer with the virtual machine can then run that same program.

This is a bit like writing a document in a widely understood language instead of a local dialect. It makes Java popular for large business systems that must run reliably for years. Banks, online shops and many apps quietly run on Java behind the scenes.

A practical example

A regional bank’s payments team maintains a Java 11 service that validates and routes card transactions. At peak times, the service handles several thousand requests per second, and thread pools limited to a few hundred platform threads cause queueing whenever a downstream fraud check slows down.

The team upgrades to Java 21, switches the request handling to virtual threads and changes the garbage collector from G1 to generational ZGC. No business logic is rewritten. Load tests show that the service now keeps many more requests in flight during slow fraud checks, and pause-related latency spikes drop to sub-millisecond levels, so the bank meets its response-time targets without adding servers.