Java language to introduce the Java virtual machine, running with the cross-platform functionality, able to adapt to a variety of Web applications. At the same time, Java language in order to improve the performance and robustness, but also the introduction of mechanisms such as garbage collection and other new features, through these improvements so that Java has its own unique works.

1. Java Virtual Machine

Java Virtual Machine (Java Virtual Machine, JVM) is a computer simulation software, it can be in any processor (whether in the computer or other electronic equipment) compliant implementation of the security stored in. Class file byte code . Java Virtual Machine “Machine Code” kept in. Class files, and sometimes can also be referred to as byte-code files.

Cross-platform Java program characteristics mainly refer to byte-code files can be in any Java virtual machine with a computer or electronic devices, Java Virtual Machine in the Java interpreter is responsible for the interpretation of byte-code file to run a particular binary . So at runtime, Java source code need to be a compiler to compile. Class files.

Java virtual machine to establish the need for different hardware and software platform to achieve, it is necessary to consider the processor model, we should also consider the type of operating system. Resulting in the SPARC structure, X86 structure, MIPS and PPC chips, such as embedded processing, in UNIX, Linux, Windows, and some real-time operating system on the Java virtual machine can be realized.

2. Automatic recovery mechanism useless memory

In the course of the implementation of the procedures, some of the memory in use after the middle of the abandoned state, if we do not recover in time, is likely to lead to memory leaks, which lead to system crashes. In C + + language by the programmer to carry out the recovery of memory, programmers need to program in the preparation of the object to the use of memory is no longer off the release of this man-made memory management method of release is often due to the negligence of a programmer can not recall a result of memory At the same time also increased the workload of programmers. Running in the Java environment, there is always a system-level threads, dedicated to track memory usage, no longer used regularly to detect the memory, and automatically recover and avoid a memory leak, but also to reduce the programmers workload.

3. Code security checking mechanism

Always a relatively safe and convenient contradictory. The emergence of Java programming language allows the client computer from the network can easily upload or download the Java program to run on the local computer, but how to ensure that the Java program does not carry the risk of viruses or any other purpose? In order to ensure that procedures for the implementation of Java security, Java language through the procedures to control illegal Applet security procedures, that is, it only has to ensure that the Java language’s survival.

The implementation of Java byte code to go through the following three steps:

(1) classloader (class loader) is responsible for the class file (. Class files) loaded into the Java virtual machine. In the process of such documents need to be inspected in line with the class file specification.

(2) byte-code validator (bytecode verifier) to check the code of such a document the existence of some illegal operation, such as programs written Applet local computer file system.

(3) If the byte-code validator test passed, by the Java interpreter is responsible for the interpretation of such documents for the implementation of Machine Code.

Note:

Java virtual machine “sandbox” mode, that is, the Java program code and data are limited to the implementation of a certain memory space, does not allow access outside the memory space of memory. Applet process if it is also not allowed to visit the client machine file system.
Java Runtime Environment

No matter what language it requires a specific operating environment, which is the platform. Java is no exception to the same language. But how to understand the procedures and hardware environment Java has nothing to do it?

Almost all the languages through an interpretation of the compiler or the computer can be implemented, but a little different from Java, it needs these two processes at the same time. In fact, for this reason it is only to make Java the language has nothing to do with the platform of. When, after the completion of a Java source code, first of all, through the Java compiler translation process it into an intermediate byte code called code, and then explained by the Java platform as a device to convert it to machine language implementation of the core of this platform is JVM.

The process of compiling Java and other languages. Such as C + + language, it is a compile-time in the computer hardware platform information inseparable. Compiler directives through look-up table of all the operands and opcode into memory, such as offset, that is, running the memory allocation procedures designed to ensure normal operation. Java is the conversion will become a kind of instruction. Class files, this file does not contain hardware information, the need for as long as after the implementation of the machines installed JVM to explain, after the creation of memory allocation through the look-up table to determine where a directive address. This will effectively ensure the portability of Java and security.

Java platform with such features and its structure. Usually a program running on a platform is a hardware or software environment is currently more popular Windows XP, Linux, Solaris and MacOS. Not as a platform for Java, which is composed of two parts, namely, JVM and application programming interface.

1. JVM

JVM is the core Java platform, in order to allow the compiler to generate the byte code interpretation and implementation of better, so the JVM has been divided into six parts: JVM interpreter, command systems, registers, stacks, storage areas and debris recovery area.

◆ JVM interpreter: that is, the virtual machine code to deal with field CPU.

◆ JVM command system: the system is very similar to the computer, a command from the operation code and operands of two parts. Opcode for an 8-bit binary number, mainly to illustrate the function of a command, the operation could be based on needs, JVM as many as 256 kinds of different operating instructions.

◆ register: JVM has its own virtual register so that you can quickly and JVM interpreter of data exchange. Needs in order to function, JVM settings of the four commonly used 32-bit registers: pc (program counter), optop (Top-pointer operand), frame (the current implementation of environmental indicators) and vars (point to the current environment, implementation of the first local variable pointer).

◆ JVM stack: instruction execution data and information stored at the sites and the control center, which provides JVM interpreter to the computing the required information.

◆ Storage Area: JVM memory used to store the byte-code compiler, such as after the information.

◆ debris recovery area: JVM debris recovery refers to the use of the Java type of concrete examples to recall from memory, which allows developers to program their own control eliminates the trouble and the risk of memory. With the continuing escalation of JVM, the debris recovery techniques and algorithms are also more reasonable. JVM 1.4.1 version is called after hours on behalf of a collection of technologies, the use of the object is simply to survive in the procedure time is divided into generation, as debris recycling standards.

2. Java Application Programming Interface

Java Application Programming Interface referred to as Java API, the Chinese called Java Application Programming Interface. It is a software collection, many of which required the development of the control, you can use it to support the development.

Java API and JVM running Java constitutes a basic environment, and these two together in the computer software on through these two software, Java platform, a Java application separated from the hardware system, which guarantees a very good program independence. In order to better adapt to the needs of development, Java’s designers have provided three kinds of versions of Java platform: Java 2 Micro Edition (J2ME), Java 2 Standard Edition (J2SE) and Java 2 Enterprise Edition (J2EE), each version provides a wealth of development tools to meet the different needs of the development.