The first simple explanation of the Java cross-platform features is equivalent to saying that a Java program can run on different operating system platforms (the platform here is simply viewed as an operating system platform). Let's use some examples to illustrate its benefits.
We first understand some basic knowledge, the computer is composed of hardware and software, software is divided into system software and application software. Install the system software on the hardware first, install the application software on the system software, and they are compatible with each other, as shown in the following (Figure 3-1):
(Fig. 3-1)
Compatibility issues between software let's look at the following example (Figure 3-2):
(Fig. 3-2)
When we download the software, we often see such a picture, you can imagine that you use an Android phone to download an Apple version of the small Deanne software, the normal installation run it? Of course not. So we can understand that, in order to meet the different operating system users need to develop different versions of the small Deanne software, the workload is obviously very large. Wouldn't it be nice to develop a set of small Deanne software that could run directly on different operating systems?
The principles of the Java Cross-platform we can look at in such a few steps:
① first to install a JVM (Java Virtual machine) software on different operating systems;
② Compile the Java source files (. java files) into bytecode files (. class files);
The ③ then loads the bytecode file into the JVM, no matter what the operating system is, as long as it is installed in the Java operating environment;
④ Note: The JVM itself is also software, so different versions of the JVM need to be developed for different operating systems, but this does not bother our program ape, because the Java team itself has provided many of the JVM supported by the mainstream operating system.
In summary, Java implements its cross-platform features indirectly through the JVM (Java Virtual machine).
Example interpreting the cross-platform principle of Java