+ 1
Why java is platform independent?
2 Antworten
+ 2
First of all, a platform is anything on which a program is run(in lay man term). A platform is either the machine itself, or a primitive kernel or a fully developed OS. Languages can be platform dependent or independent.
Dependent means its executable code and source code varies from platform to platform. That is to say that the programmer has to make some changes in the code if it has to run on other platforms. Languages like C are platform dependent.
Platform independent means that the code remains the same irrespective of the platform involved. Java has something called a virtual machine called JVM or Java Virtual Machine. What happens in case of Java is that the JVM once installed on any platform like windows or OS X can run the java code without any alteration. The JVM acts like a virtual platform on which the code is executed. As the platform being JVM remains constant throughout all platforms Java programs can run on any platform irrespective of the real platform.
If you want to know the detailed process then it is here: Java source code written in the high level java is first converted to something called the javabyte code. This byte code is not readable by the original platform, but only the JVM can read it and then it executes it. This is the primary reason why Java is much in use even today.
0
Shortly: Java applications do not run on a platform but on JVM :)