Java Learning Java's operating environment

Source: Internet
Author: User
Tags execution interface
Java is already very popular nowadays. Every day, more than millions of programmers in the world are using Java for program development. The program written in Java is more and more favored by people because of its independent hardware environment. If you want to be part of the Java world, it might be helpful to look at this series of articles.



No matter which language needs to have its specific operating environment is the platform, Java is no exception. You might ask, is the Java program not a hardware environment independent? Well, I hope this article will answer this question.

Almost all languages need to be compiled or interpreted to be executed by your computer. But Java is a little different, and it requires both processes. In fact, it is precisely for this reason that the Java language has a platform-independent nature. When you write a Java program (of course you don't really write Java programs at this point). First, it is compiled into an intermediate code called bytecode by a translation program. It is then translated by the Java platform interpreter into machine language to perform the core of the----platform called the JVM (Java Virtual machine). The Java compilation process is also different from other languages. For example, a language like C + +, when compiling, is closely related to the hardware platform information of the machine. The compiler converts the operand and opcode of all instructions to the memory offset, which is the memory allocation mode of the program running, to ensure the program running. Java, however, transforms instructions into a *.class file that does not contain hardware information. When you need to do this, simply install the JVM's machine to explain, create the memory layout, and then check the table to determine the address of an instruction. This effectively guarantees the portability and security of Java. So why does the Java platform have such a good feature?

Typically, a program runs on a platform that is a hardware or software-run environment. The current popular is Windows MacOS, Linux, Solaris, and the. Java platform is not the same, it consists of two parts: one is the Java Virtual machine Java VM, the other part is the Java application Programming Interface (Java API) Java application design interface, these two parts of software constitute the basic environment of Java operation. The Java API is a large set of already-done software that has many of the controls it needs to develop to assist in development. The Java API and JVM are integrated on top of the machine hardware. In other words, the Java platform separates a Java application from the hardware system, which guarantees the independence of the program. To better meet the needs of development, Java designers have provided us with three Java platforms: Java 2 Micro Edition (J2ME), Java 2 Standard Edition (J2SE), and Java 2 Enterprise Editi On (Java ee). Each release provides a rich development toolbox to accommodate different development needs.

Let's take a concrete look at the concrete structure of the Java platform's core JVM.
To allow the compiled bytecode to be better interpreted and executed, the JVM is divided into 6 main chunks: JVM interpreter, instruction system, register, stack, storage area, and fragment recycle area.

The JVM interpreter is the CPU for the processing field code of this virtual machine.

The JVM instruction system is similar to a hardware computer. An instruction is divided into two parts: operation code and operation number. The opcode is 8-bit binary, and the operands can be determined as required. The opcode is designed to illustrate the function of an instruction, so the JVM can have up to 256 different operating instructions.

The JVM has its own virtual registers, so that it can quickly exchange data with the JVM's interpreter. For functional purposes, the JVM sets up 4 commonly used 32-bit registers: PC (program counter), Optop (operand stack top pointer), frame (current execution environment pointer), VARs (pointer to the first local variable in the current execution environment).

The JVM stack is the place and control center for data and information storage at the time of instruction execution, and it provides the information needed for JVM interpreter operations.

The JVM store is to store information such as compiled bytecode.

JVM Fragmentation Recycling is the use of specific instances of Java classes that have been used to recycle from memory, which frees developers from the hassle and danger of programming control over memory. As the JVM continues to escalate its technology and algorithms for fragmentation recovery are more reasonable. The classic algorithms include reference counting, copying, labeling-clearing, and labeling-sorting. After the JVM1.4.1 version of the generation of a call to collect technology, simple is to use the object in the program to survive the time to divide into a generation, this is the standard for debris recycling. The scrap collection will be specifically covered in future articles.

Finally, through this article I hope that we can make the Java platform for a more clear understanding of the operation. In the next article, "The first step on the Java learning Journey," I'll show you how to install a Java platform and how to start our first applet.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.