The relationship between Java, JVM, and the operating system. It is written to newcomers, and javajvm.
Laitu: This post was written to a newbie, and old players directly ignored him, because it is completely the basic principle of the vernacular.
Explanation: the figure above shows the call relationship from top to bottom.
The operating system (Windows/Linux) manages hardware and enables the hardware to run properly and reasonably. Of course, various hardware drivers implement the interfaces of the operating system, the operating system can manage hardware by calling these interfaces. The operating system also provides an interface called the system call layer for programmers to program interfaces at this layer to implement computer control, the interfaces provided by different operating systems (or different CPU architectures) are different. The interfaces provided by Windows and Linux are definitely different, although it is possible to achieve a certain function from the final point of view. Therefore, the same program cannot run on different systems, or even different versions of the same system may not run perfectly. This is called a platform-related program, for example, C/C ++ programs, but with the rapid development of computers and the Internet, there are tens of millions of computer types and models, and there are also many types of operating systems, such as Windows, Linux, and iOS, the same software can run on different operating systems without making any changes, which is not very friendly to developers. The Java language can solve this platform (it is said that the Java platform is more accurate, and the JVM + JavaAPI). In view of the different operating systems that require different programs, then we can find a way to solve this problem, so the JVM was born, and the JVM was connected down to all operating systems. It was able to operate all operating systems and provide unified interfaces upwards, that is, Java API. Developers only need to program the JVM (Java API). Developers do not need to worry about how the JVM is dealing with different operating systems, therefore, as long as it is oriented to JVM + Java API programming, a program can run on any operating system platform. This is called cross-platform. Java code has nothing to do with the platform. --- This is the cross-platform nature of Java.
In fact, this idea is the same as the Linux shell. the Linux operating system manages the hardware and provides a unified interface for Linux, while the Shell (just like the above JVM) as the intermediary between the command input and the operating system interface, the man-in-the-middle will explain the input command to the operating system interface to manage and call various hardware, but the shell is not as thorough as the JVM, that is why the input commands are basically the same for so many different shells.
For example, there are many dialects in our country. For example, Guangdong People can only understand Cantonese and Tianjin people can only understand Tianjin. These dialects are the so-called regional languages, computer software is platform-related. If a beijingman wants to speak to Guangdong, Sichuan, and Tianjin, I must speak these three dialects, which is very painful for my language skills, learn these three things. However, we know that Hunan Satellite TV Wang Han is awesome and can speak various dialects. I invite him as a translator. Wang Han is a JVM. He can speak these three dialects, and he only understands Mandarin, however, it seems strange that all people who want to deal with Guangdong, Sichuan, and Tianjin speak Mandarin with Wang Han and ask him to help translate, let's talk about his translation statement. In this way, we only need to learn Mandarin to communicate with anyone. This is the Java platform. Because of the Process of intermediate translators, it is obvious that communication between Mandarin and Cantonese is very slow. If I need to wait for Wang Han to translate, I must not speak Cantonese directly. This is why Java is slower than C/C ++. The virtual machine must explain the execution. Although the speed is slow, what we get is that we only need to speak Mandarin to communicate with everyone. This price is worth it, and the development of virtual machine performance and various Java technologies are also the same, the execution of this explanation is getting faster and faster, and may catch up with C/C ++ in the future, that is, Wang Han's speech speed will become better and better, it is faster for us to communicate with people in different regions. Of course, the current JVM is not just a line-by-line explanation, but also some JIT technologies and many other improvements.
What is the relationship between JVM and the operating platform?
Not necessarily connected. Like cities (WINDOWS, LINUX, IOS) and buildings (JVM), there are also many buildings in many cities around the world. You can select any floor to live (write a program ). The analogy is not very appropriate, but it does.
Who told me about the relationship between the Java runtime system and Jvm?
JVM java virtual mechina is the JAVA virtual Machine Used to interpret java bytecode.
Java runtime system is java runtime environment (I .e., JRE: java runtime environment
JDK java development kit: a Java development Tool usually contains JRE in JDK, but running a Java tool does not require JDK 2 and JRE.