Java Features
Java's design was shaped by a specific set of goals: run the same program on any machine, make large programs safer to write, and keep code readable over many years of maintenance. Each feature below exists to serve one of those goals. Understanding the reasoning behind each one explains many of the rules you will meet later in the language.
Platform Independence
Java source code compiles to bytecode, not to native machine instructions. Bytecode is executed by the Java Virtual Machine (JVM), and a JVM exists for every major operating system and processor architecture.
Program.java
|
javac
|
Program.class (bytecode, identical on every platform)
/ | \
JVM on JVM on JVM on
Windows Linux macOS
The practical consequence: you compile once and ship the same .class or .jar files to every platform. A build server on Linux can produce artifacts that run unchanged on a developer's Mac and a customer's Windows server.
Compare this with C or C++, where a program must be compiled separately for each target platform, and the resulting binaries are not interchangeable.
What platform independence does not cover
The bytecode is portable, but your program can still make platform-specific assumptions. File path separators (