Technical features and operating mechanism of Java

Source: Internet
Author: User

2017.11.5 Yin

First, the technical characteristics of Java

Java contains a lot of technology, from the whole, Java technology can be divided into: Java programming language and Java platform

The Java programming language is an advanced programming language with the following features:

> Simple > Structural neutrality

> Object-oriented > Robustness

> Highly portable > High performance

> Multithreading > Security

> News

1. Cross-platform

  The so-called cross-platform, the software can be free from the computer hardware and operating system constraints and in any computer environment, normal operation. This is the trend of software development and the goal that programmers pursue.
The reason is that because of the wide variety of computer hardware, operating systems are different, users and companies have their own different computer environment preferences, and software in order to
Operating in the same environment, you need to be independent of these platforms.
In the Java language, Java-brought virtual machines are a good way to achieve cross-platform. Java source code is compiled and generated binary bytecode is platform-independent, but can be
A machine code directive that is recognized by a Java virtual machine. Java virtual machines provide a barrier to the underlying hardware platform and operating system, making the Java language cross-platform.

 2. Object-oriented

Object-oriented refers to the object as the basic granularity, which contains properties and methods. The description of the object is expressed in attributes, and the object is manipulated by using a method. Object-oriented technology makes application development easy to use,
Save code. Java is an object-oriented language and also inherits many of the benefits of object-oriented, such as code extension, code reuse, and so on.

3. Security

security can be divided into four levels, namely, language-level security, compile-time security, run-time security, executable code security. Language-level security refers to the data structure of Java as a complete object, which is encapsulated
type has security. Compile-time Java language and semantic checks to ensure that each variable corresponds to a corresponding value, compiled after the Java class. The runtime Java class requires the ClassLoader to load and pass the byte-code Checker
can only be run after the test. When a Java class is used on a network, its permissions are set to ensure the security of the user being accessed.

4. Multithreading

Multithreading has been the most successful application in the operating system. Multithreading refers to allowing an application to have two or more threads at the same time to support transactional concurrency and multi-tasking. Java in addition to the built-in multithreading
Technology, some classes, methods, and so on are defined to establish and manage user-defined multithreading.

5. Easy to use

Java source code is written in a specific environment, you can use Notepad, text editor and other editing software to implement, and then compile the source files, compiled through the direct operation, through debugging can get the desired results.
Ii. compilation and operation of Java programs

As we all know, the computer can not directly understand the source code in the high-level language, can only directly understand the machine language, so must be "we say" translated into "machine can understand the language", so that the two can communicate effectively, the computer can also perform advanced
Language programming.
There are two ways to translate: one is compile, the other is explanation. The two ways are only different in the time of translation.
As a compiled language, all of the source program files in Java are compiled to produce a unified intermediate language called Java bytecode, unlike the C language that generates specific hardware and operating system platforms, after the Java program compiles
The resulting bytecode is the same for all computers. Because the compiled file name suffix is. class, the bytecode file is also known as the Java class file.
As an interpreted language, a bytecode file generated by the Java source code cannot be executed directly, and a program called a Java Virtual machine (Java VM, or JVM) is required to be translated into a local machine code.
Before it can be executed.

Let's take a look at a picture below:

 

1. Compiling

The Java compiler incorrectly processes the source files, and compiles a bytecode file with a. class suffix. So that the interpreter in the JVM (Java Virtual machine) can read it properly.

2. Operation

Three-Step code loading, code validation, and code execution

2.1, the Code loading

The class loader in the JVM control interpreter goes to read and load the classes required by the program (the class's bytecode). The interpreter then begins to establish the relationship between the class and the class.

2.2, the code of the check

Byte-code checker checks: The validator can find the operand stack overflow, illegal data type conversion and many other errors.

2.3, the execution of the Code

3. Implementation

There are two cases of execution
Instant Compilation: The interpreter compiles the bytecode into a machine code before executing the machine code.
Explanation of execution: The interpreter completes all operations of the Java bytecode program by interpreting and executing a small piece of code each time.
The second method is usually used. Because the JVM specification is sufficiently flexible, this allows the translation of bytecode into machine code work


There are two ways the JVM runs Java programs : Jar package with Class
When running the jar, Java.exe calls the Getmainclassname function, which first obtains the JNIEnv instance and then calls Getmanifest () in the Jarfilejnienv class, fetching from the manifest object it returns
The value of Getattrebutes ("Main-class"), which is the file in the jar package: Meta-inf/manifest. The main class of the Main-class specified by MF is the main class of the run. The main function then calls the JAVA.C
The LoadClass method loads the main class (using the Findclass of the JNIEnv instance).
When you run class, the main function directly calls the LoadClass method in JAVA.C to load the class.

Technical features and operating mechanism of Java

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.