Introduction java read a lot of books , the book is often said that the purpose is to make java program can run on different platforms. But a closer look , and that requires a corresponding virtual machines running on each platform. So
c language : code - > different platforms with different compilers - > Run .
java: code - > different platforms with different virtual machine - > Run.
Since this cross-platform C language runtime and what a difference?
is not a new platform for the production of a virtual machine is easier than making a compiler ?
------ Solution ------------------------------------ --------
c language programmer gave too much power , you can not stop by c language for system calls , so unless specifically written in portable c program , or generally not cross-platform .
The java language is different, no matter what program you write (jni excluded), are interpreted to go through a virtual machine , so is cross-platform
------ Solution ---- cross-Platform ----------------------------------------
java refers java run time above the os, is running in the jvm , and no direct contact with the os .
If you have the opportunity to write data into the interaction between export, and server applications , you will know that " cross- platform" has little meaning .
Before java, cross-platform is a very painful thing , mainly because of all the calls the system under different operating systems are not the same result , the simple , the length of the int in a different operating system on the inside not the same, even with the byte order of arrangement is different. Call the same function returns the format is different, and therefore , they have to write a program people are very understanding of the different systems , if you really need to be compatible with different operating systems , a lot if you want to write a program which , when compiled first judgment operating system used to create a lot of environment variables to compile , but compiled binary executable files can be run on the system . If you write a function library for others to call , then the light of the judgment of the operating system accounted for the majority of the code, but , you also tested under different platforms , this is an arduous task. I suggest you have time you can see apache httpd server source code to know.
Since With java, put the operating system is compatible to work threw the jvm , and the programmer will never again have several concerns int , as well as the previous high was a question of the status of the former you just use java code to your program logic can be achieved out of these compatibility problems jvm go on to deal with it . Thus, if you write a program delivered to customers, if the customer is running AIX environment , you do not need to install a locally also to develop and run AIX , you can complete all development on the windows, and then put a good compilation the file can be handed over to the customer , since there is something customers need to run this program on Solaris , you do not have to modify , you can directly take over running is not it a convenient? Only the cross-platform development tortured people to get a deeper experience to the development of cross-platform applications using java advantages .
------ Solution ------------------------------------ --------
java java compiler cross- platform is decided , because he is by jvm java java virtual machine to compile the execution , he compiled class file is not for the realization of the underlying operating system , all of what the operating system does not affect the execution of java code.
------ Solution ---------------------------------------- ---- cross-platform
java java refers to a program written to run on multiple operating systems , because it is actually run by a virtual machine is independent of the operating system , but there is no cross-platform C language because it only runs on Windows operating systems , because of the recognition of the C language program on Windows.
------ Solution ---------------------------------------- ----
JAVA platform is that we boast programmers write programs as long as the tube structure algorithms, this program is you do not control what the system is running . Because different systems have different systems api ( understood as some of the computer's functions can be controlled it, such as displaying an image of what ) , that you write on a different system program will be different , but the java is platform boast the same What systems can run the program . JAVA platform can boast because java is running on a virtual machine JVM , JVM solve different platform (which explained JVM is not the same for each platform is a platform for writing ) , I cross the door to write JAVA code to the JVM translation, translate it cost to machine code , so that the JAVA platform is exaggerated , but it is not cross-platform JVM
------ For reference only --------------- ------------------------
means of cross-platform java virtual machine to complete, and c language compiler did not handle cross-platform ( system calls, based on a compiler syntax certain library functions , based on a specific cpu -word programming , etc. )
------ For reference only ----- ----------------------------------
say good
- ---- For reference only ---------------------------------------
< br /> that is very detailed
------ For reference only ------------------------------- --------
once programmed , can be different
------ For reference only run on an operating system ----------------- ----------------------
class files cross-platform , jvm can not be cross-platform, you write cross-platform java you , anyway, you do not control jvm
------ For reference only --------------------------------------- < br>
------ For reference only ---------------------------------- -----
java. . . Write once , run everywhere . . . . . Just write once , do not need to write any platform to the . And c language but not so. . .
------ For reference only -------------------------------------- -
by jvm, compile a java program can run on a computer jvm 's
------ For reference only in each ---------------- -----------------------
I think the 6th floor :
java java compiler cross- platform is decided , because he is by jvm java java virtual machine to compile the execution , he compiled class files are not aimed at the realization of the underlying operating system , all of what operating system does not affect the execution of java code.
explained very clearly ~ ~ ~
------ For reference only -------------------------- -------------
6th floor upstairs think it is clear ? I think it is rather clear 2,3 floor , you do not say a bunch of what jvm class for the operating system or something, then I can also say that C language can be to face different operating systems with different compilers !
没有评论:
发表评论