A Java source file is compiled to generate one or more .class files. These contain bytecode. Bytecode is a set of instructions that can be interpreted by a Java Virtual Machine (JVM). Many systems come with a JVM installed by default. The JVM can also be downloaded from the Sun web site, http://java.sun.com/.
The key to Java’s platform independence is that the same bytecode can be interpreted by JVMs on any hardware platform. This allows you to compile a Java program into bytecode on a UNIX system, for example, and then use a JVM on a Windows machine to run the program from the bytecode. Since JVM implementations are available for virtually all modern systems, Java programs are highly portable.
It is possible to find software that compiles Java programs directly into native executables. Although this allows for faster performance, these executables are platform-specific and cannot be run on other systems.