Home Segments Top Top Previous Next

4: Mainline

To make Java programs portable, so that they will run on a variety of hardware platforms, the Java compiler translates the programs into byte code. Such translated programs are said to have been compiled into byte code.

Programs translated into byte code seem to be written in the instruction set of a typical computer, but byte code is neutral in that it does not employ the instruction set of any particular computer. Instead, byte code is executed by a program that pretends that it is a computer based on the byte-code instruction set. Such a program is called a byte-code interpreter. A byte-code interpreter intended to execute the byte code produced by the Java compiler is called a Java virtual machine.

Once a Java virtual machine has been implemented for a particular computer, that computer will run any compiled Java program. Or, said the other way around, any Java application will run on every machine for which a Java virtual machine has been implemented.