How java solved portability?


Java compiler converts java code to bytecode and then JVM converts bytecode to machine instructions . As far as I have understood , JVM are built for different platforms (processor + OS) then how can we say that java is platform independent . Ultimately we require a JVM which is platform dependent ?

>Solution :

The end-user writes code in java and that is platform independent.

The JVM engineer works on creating the JVM and the JRE and within it the compiler and the interpreter for different platforms. Therefore that absolves the end-user to worry about porting their codebase to different platforms. Write once and then run it on all platforms (as long as there is a JVM available for that platform).

So from the perspective of the end-user (Java programmer) the java code is indeed platform independent. Even though the JVM is ported to different platforms and is indeed platform dependent.

Leave a Reply Cancel reply