I have always been confused about Java's cross-platform and C portability. Here is my personal understanding.
1. the portability of C needs to be compiled into different target code multiple times on different operating systems, and even different code needs to be compiled for different operating systems. Java has JVM support, this saves you trouble.
2. cross-platform Java is a compilation, which can be run everywhere relying on JVM.
I think it makes sense to see a man-in-law's speech on the forum.
Before Java, cross-platform operations were quite painful, mainly because the results of all system calls were different under different operating systems. Simply put, the length of the int is different in different operating systems, and even in different bytes. The format returned by calling the same function is also different. Therefore, the program writer needs to be familiar with different systems. If it is necessary to be compatible with different operating systems, to write a lot of if in the program, you must first determine the operating system used during compilation, create a lot of environment variables before compilation, and the compiled binary executable files can only run on the system. If you write a function library for others to call, your judgment on the operating system accounts for the majority of the code, and you need to test it on different platforms, this is a tough task. We recommend that you have time to read the source code of the Apache httpd server.
Since Java was available, the work of operating system compatibility has been lost to JVM. For programmers, there are no more concerns about the number of digits in int, and there is still the problem of having a high position or a leading position, you only need to use the Java code to implement the logic of your program. These compatibility issues should be handled by JVM. In this way, if you write a program and deliver it to the customer, if the customer's environment runs Aix, you do not need to install an AIX locally for development and operation, you can complete all development on Windows, and then hand over the compiled file to the customer. In the future, other customers will need to run this program on Solaris, and you do not need to modify it, it can be run directly from the past. Isn't this convenient? Only those who have been suffering from cross-platform development can gain a deeper understanding of the advantages of developing cross-platform applications using Java.
In addition, I would like to refer to a section on PHP cross-platform understanding.
It's not too short for me to use PHP. It's only about four years. Now I basically don't need it. I switched to Java instead.
It's not because PHP is not good. I personally like PHP.
However, many of my programs need to be moved and used on the M $ and Linux platforms (because I cannot restrict the user's platforms)
If PHP is used, many extensions are not commonly used on the two platforms, and some do not even support
To write two versions for a program or write a lot of judgments in the program, I think my time and energy are not enough.
To use Java instead, you only need to install the corresponding JVM on the running platform. I just want to run my program correctly, and I don't need to worry about the rest.
BTW:
I don't think Java is a golden oil, and it can be used everywhere. I just think it can save some time. Why ?? Now the machine configuration is good, and the running performance is almost okay :-)