1: Java Architecture

Source: Internet
Author: User
Java Architecture

The core of Java technology is the Java Virtual Machine-All JavaProgramAll are running on it.

The Java architecture includes four independent but related technologies:

1. Java programming language
2. Java class file format
3. Java application programming interface (API)
4. Java Virtual Machine

Java Virtual Machine

Java's network-oriented core is the Java Virtual Machine. It supports three pillars of Java's network-oriented architecture: platform independence, security, and network mobility.

A Java virtual machine is an abstract computer that standardizes the features that every Java virtual machine must implement, but leaves many choices for each specific implementation.

The main task of the Java Virtual Machine is to load the class file and execute the bytecode. A class loader can load class files from programs and APIs. The bytecode is executed by the execution engine.

Different Java virtual machines may implement different execution engines.

1. in virtual machines implemented by software, the simplest execution engine is to interpret bytecode at one time.
2. Real-time compilation. the bytecode executed for the first time will be compiled by the Local MachineCodeThe locally compiled machine code will be cached and can be reused when the method is called later.
3. the adaptive optimizer interprets bytecode at the beginning of the VM, but monitors the activity of running programs and records the most frequently used code segments. When the program is running, the virtual machine only compiles the Code with the most frequent activities at the cost. Other codes are retained as bytecode because they are not frequently used, and the virtual machine will continue to explain them.

So sometimes Java virtual machine is called Java interpreter. however, considering that the methods for executing bytecode may be different, it may be misleading. "Java interpreter" only indicates "Java Virtual Machine", but it does not have any meaning of execution technology.

Java has two methods: Java method and local method.

Local method: a Java program can load a dynamic library containing this local method through a local method interface (Java Native Interface, JNI) and call this method. once a local method is called, your Java program loses platform-independent features and is related to specific Java platform implementations. because the local method you call may not be implemented or absent on other platforms, and the implementation of other Java platforms may not support JNI calls at all, at this time, your Java program may only be able to run on a specific platform.

Java method: It is written and compiled into bytecode by the Java language, stored in the class file, and executed by the Java Virtual Machine. although the Java Virtual Machine Platform calls the implementation of local methods to complete program functions, the APIS or methods used in these Java programs can be implemented by all Java platform vendors, because the implementation of these Apis or methods is included in the virtual machine specification. therefore, as long as your Java program has not manually called the local method through JNI, your program is platform-independent.

Class Loader: Start the class loader and user-defined class loader

The class loader is the only one in the system and is part of the implementation of the Java Virtual Machine.
The custom class loader can be dynamically installed when Java applications are running.

When a class is loaded, the Java Virtual Machine monitors the class to see whether it is started or loaded by the user class loader. When the loaded class references another class, the virtual machine uses the class loader that loads the first class to load the referenced class.

Because the Java virtual machine uses this method to load classes, only the classes loaded by the same class loader can be seen by default. In this way, the Java architecture allows multiple namespaces to be created in a Java application. Each Class Loader in the Java program at runtime has its own namespace. This restricts mutual access between codes from different sources and effectively improves program security.

Java class file

Java class files mainly adapt Java to the network in terms of platform independence and Network Mobility.

Platform independence: Generally, binary executable files on one platform cannot work on other platforms. Java class files can run on any hardware platform and operating system supporting Java virtual machines.
Network Adaptability: class files are designed to be compact, so they can be quickly transmitted over the network. Secondly, because Java programs are dynamically linked and dynamically scalable, class files can be downloaded only when necessary.

Java API

Java API is a collection of runtime libraries. It provides a set of standard methods for accessing host system resources. Java API is relatively secure, and it is a prerequisite for ensuring platform independence, Because Java Virtual Machine and Java API class files are necessary for any Java platform. Before a platform can support Java programs, it is necessary to explicitly implement API functions on this specific platform.

Java programming language

Although Java is made for the network, many people may use Java to write programs because they want to take advantage of the Java programming language.

1. Object-oriented
2. Multithreading
3. Structured error handling
4. Garbage Collection
5. Dynamic connection
6. Dynamic Scaling

These advantages can greatly improve the programmer's efficiency and enhance the robustness of the program. Compared with the old Program Design Technology (C/C ++), they have excellent performance.

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.