(1) c/c is compiled into the corresponding platform, cross-platform needs to use the corresponding compiler to recompile
(2) java is the file (.java ) is compiled into a bytecode file (.class), and then the bytecode is interpreted into machine code on the java virtual machine
(3) The bytecode (.class) file is not oriented to any specific platform, only to Virtual machine
(4) The virtual machines of different platforms are different, but they have the same interface
(5) The Java language compiles the file once and runs it everywhere (as long as the platform it is running on is installed java virtual machine). So because of this principle, the performance of c/c is higher than that of java.
Recommended learning: java video tutorial
In layman’s terms, it is better to say that Java can be cross-platform than to say that Java virtual machine (jvm) is cross-platform. The platform is like a Chinese who goes to a foreign country. He needs to bring different translators to different countries. This translator is the virtual machine (jvm). What the Chinese speak is a .java file. The translator needs to translate what he speaks into the corresponding language. This It is a .class file, thus realizing the cross-platform of java. As long as there are corresponding jvm under different operating systems, it can be said that this system can execute java.
Recommended related articles and tutorials: java introductory tutorial
The above is the detailed content of Introduction to java cross-platform principles. For more information, please follow other related articles on the PHP Chinese website!