Java is described as "write once, run anywhere". What makes this possible, and is the JVM itself platform independent?
Show the explanation
javac does not produce machine code for one processor. It produces bytecode — instructions for an abstract machine, stored in .class files. Any computer with a JVM for its OS and CPU can run that same bytecode.
Hello.java --javac--> Hello.class (bytecode) --JVM on Windows / Linux / macOS--> runsSo the program is platform independent, but the JVM is not: each platform needs its own JVM build. Portability also depends on the code itself — hard-coded file paths like C:\data, OS-specific line endings or native (JNI) libraries can still tie a program to one platform.
Original UniCircle question. Last reviewed 22 Oct 2026.
