1.4. The Java Environment

You can run Java programs on a wide variety of computers using a range of operating systems. Your Java programs will run just as well on a PC running any supported version of Microsoft Windows as it will on Linux or a Sun Solaris workstation. This is possible because a Java program does not execute directly on your computer. It runs on a standardized environment called the Java 2 Platform that has been implemented as software on a wide variety of computers and operating systems. The Java Platform consists of two elements—a software implementation of a hypothetical computer called the Java Virtual Machine (JVM) and the Java Application Programming Interface (Java API), which is a set of software components that provides the facilities you need to write a fully fledged interactive application in Java.

A Java compiler converts the Java source code that you write into a binary program consisting of bytecodes. Bytecodes are machine instructions for the Java Virtual Machine. When you execute a Java program, a program called the Java interpreter inspects and deciphers the bytecodes for it, checks it out to ensure that it has not been tampered with and is safe to execute, and then executes the actions that the bytecodes specify within the Java Virtual Machine. A Java interpreter can run standalone, or it can be part of a web browser such as Netscape Navigator, Mozilla, or Microsoft Internet Explorer where it can be invoked automatically to run applets in a web ...

Get Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.