The Java compiler does in fact not produce code that can be directly executed by the computer. Instead it produces code that is independent of the specific computer and that is called Java bytecode.
Hence, the result of the compilation of a Java program is platform independent. This requires the use of a specific program that is able to execute the bytecode: the bytecode interpreter, known as Java Virtual Machine, which is activated through the command java.
To be able to execute a compiled Java program on some platform, it is sufficient to have the interpreter for the Java bytecode. This independence from the platform is one of the distinguishing features of Java that have led to a very quick diffusion of Java.