The big idea
Java is one of the most widely used programming languages in the world. It was released in 1995 and was designed around one promise: write once, run anywhere. You write your program once, and it runs on any computer that has Java installed, whatever the operating system.
If you already know some Python, a lot will feel familiar: variables, if, loops and functions all exist in Java. The big differences are that Java is compiled before it runs, every variable has a fixed type, and the code is organised with curly braces { } instead of indentation.
Explained simply
Think of a recipe written in English being translated into a universal sign language that every kitchen in the world understands. Java works in a similar way: you write the program once, it is translated once, and the translation runs anywhere.
- You write source code: the instructions in Java, saved in a file ending in
.java. - The compiler, a program called
javac, reads your source code, checks it for mistakes and translates it into bytecode. Bytecode is a compact set of instructions that is not tied to any one kind of computer. It is saved in a.classfile. - The Java Virtual Machine (JVM) is a program that runs bytecode. There is a JVM for Windows, one for macOS, one for Linux and more. Each one understands the same bytecode.