Skip to main content

What Java Is & How It Runs

beginner15 min readLesson 1 of 180

Source → bytecode → JVM: the compile-run cycle that shapes everything else in the language.

Java is two things at once: a language and a platform. You write source code in .java files; the compiler (javac) turns each file into bytecode in a .class file; and the Java Virtual Machine (JVM) runs that bytecode on any operating system. That is the famous "write once, run anywhere" — and it is also why Java feels a bit more formal than Python: the compiler reads your code before anything runs.

public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello, Code Journey!");
    }
}

Every word in that program has a job:

  • public class Hello — Java code always lives inside a class (a named container for code and data). The file must be named Hello.java: the public class name and the file name must match exactly, including case.
  • main — the entry point. When you run java Hello, the JVM looks for exactly this line: public static void main(String[] args). For now, read public static void as fixed plumbing; each word gets explained in later modules.
  • System.out.println(...) — prints a line of text to the console. The dot chain reads "from the System, go to out (the console), call println".
  • Every statement ends with a semicolon ;, and blocks of code live inside braces { }.

Two errors you will meet immediately, and both are good news:

  • Compile-time errorsjavac refuses to produce bytecode and tells you the file, line, and reason (missing semicolon, misspelled name, wrong types). Nothing runs until the compiler is satisfied.
  • Runtime errors — the code compiled, but something went wrong while running (dividing by zero, using a variable that is null). The JVM prints a stack trace describing exactly where it died.

The compiler is your first, fastest code reviewer. Beginners who read its messages carefully improve dramatically faster than those who just retype code until it works.

Vocabulary you will see everywhere

| Term | Meaning | |---|---| | JDK | Java Development Kit — compiler + tools + JVM (what you install) | | JVM | the machine that runs bytecode | | bytecode | the portable .class instructions javac produces | | JRE | JVM + core libraries (runtime only, no compiler) |

You will practice in this course's editor, which compiles and runs Java the same way javac + java do on your own machine.

Next: making the program yours — variables and types.