The Java VM

A Java virtual machine (VM) is software that implements the Java runtime system and executes Java apps. It can be a standalone app like the java program that comes with the JDK or part of a larger app like a browser. Usually the interpreter itself is a native app, supplied for each platform, which then bootstraps other tools written in the Java language. Tools such as Java compilers and IDEs are often implemented directly in Java to maximize their portability and extensibility. NetBeans, for example, is a pure-Java app. The Java VM performs all the runtime activities of Java. It loads Java class files, verifies classes from untrusted sources, and executes the compiled bytecode. It manages memory and system resources. In implementations that support dynamic compilation, the interpreter also serves as a specialized compiler that turns Java bytecode into native machine instructions. Throughout most of this tutorial, we'll be building standalone Java programs, but we'll make frequent references to Java applets as well. Both are kinds of Java apps run by a Java VM. A standalone Java app is a complete program intended to be run independently. An applet is, conceptually, an embeddable component to be used in a larger app. Both technically and in usage there is not much difference between the two, other than the Java VM can't run an applet directly. To run an applet, you must use a web browser or the appletviewer tool that comes with the JDK.