Menu

What Is Java? The Language, the JVM, and Where It Runs

What Java actually is, how the JVM lets one compiled program run anywhere, and the kinds of software Java is used to build.

This page includes runnable editors - edit, run, and see output instantly.

Java in One Sentence

Java is a statically typed, object-oriented programming language that compiles to bytecode and runs on the Java Virtual Machine (JVM). That one design choice - compile to a neutral intermediate format, then run it on a virtual machine - is the reason the same compiled Java program runs unchanged on Windows, macOS, Linux, and beyond.

Here is the obligatory first program. You can run it right here:

There is more ceremony here than in a scripting language, and that is on purpose - Java favors explicit structure. We will unpack every piece of this over the next few pages.

Why the JVM Matters

Most compiled languages turn source code straight into machine code for one specific processor and operating system. A program compiled for Windows will not run on a Mac. Java takes a detour:

  1. javac compiles your .java source into .class files containing bytecode - instructions for an imaginary machine, not any real CPU.
  2. The JVM for your platform reads that bytecode and executes it, translating to native machine instructions as it goes.

Because every platform has its own JVM but they all understand the same bytecode, you compile once and run the result anywhere a JVM exists. That is the famous slogan: write once, run anywhere.

The JVM does not just interpret blindly. A just-in-time (JIT) compiler watches which code runs most, then compiles those hot paths to optimized native code - so long-running Java programs approach the speed of fully compiled languages.

Statically Typed and Object-Oriented

Two properties shape how Java code looks and feels.

Statically typed means every variable has a type known at compile time, and the compiler checks your types before the program ever runs:

count is an int forever; assigning "hello" to it would not compile. This catches a whole class of mistakes early, at the cost of more typing up front.

Object-oriented means Java organizes code into classes - blueprints that bundle data and the methods that act on it. Even the entry point above lives inside a class Main. Almost everything you write in Java lives inside a class.

What Java Is Used For

Java is one of the most widely deployed languages in the world. You will find it in:

  • Backend and enterprise systems - banking, insurance, large web services, and anything that needs to run reliably for years.
  • Android - the platform's original language, still central to the Android runtime even alongside Kotlin.
  • Big data - Hadoop, Spark, Kafka, and much of the data-engineering ecosystem run on the JVM.
  • Desktop and embedded - from IDEs (IntelliJ, Eclipse) to point-of-sale terminals and smart cards.

Its reputation is for stability, backward compatibility, and a vast standard library, rather than for being the most concise language. Code written for Java years ago generally still runs today.

Java Is Not JavaScript

Worth stating plainly because the names cause endless confusion: Java and JavaScript are different, unrelated languages. They share four letters for historical marketing reasons and nothing else that matters. Java is compiled and statically typed and runs on the JVM; JavaScript is dynamically typed and runs in browsers and Node.js. Learning one does not teach you the other.

Next: Installing Java

To write and run Java on your own machine you need a JDK (Java Development Kit) - the compiler plus the JVM plus the standard library. The next page walks through installing it and confirming it works.

Frequently Asked Questions

What is Java used for?

Java runs large server-side and enterprise systems, Android apps (via the Android SDK and Kotlin's shared runtime), big-data tools like Hadoop and Spark, and countless desktop and embedded applications. Its strengths are stability, a huge standard library, and the JVM running the same compiled program on any operating system.

Is Java compiled or interpreted?

Both. The Java compiler (javac) turns your source into platform-neutral bytecode, and the JVM then runs that bytecode - interpreting it at first and compiling hot paths to native machine code with a just-in-time (JIT) compiler. So Java is compiled to bytecode, then interpreted and JIT-compiled at run time.

Is Java the same as JavaScript?

No - they are unrelated languages that share a name for historical marketing reasons. Java is a statically typed, compiled language that runs on the JVM; JavaScript is a dynamically typed language that runs in browsers and Node.js. Knowing one does not mean you know the other.

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED