- Java is known as platform independent language unlike C, C++ (both of these are platform dependent language).
- In C, C++ if you wrote a program (on Windows 7), and in case you want to execute it on some other OS (operating system) like Linux, then it will throw you numerous errors. So you will have to re-write the whole program using Linux defined syntax, which is very time consuming.
- While in Java this is not the case. Same program can be every easily executed on any Operating System, without reprogramming the whole program for that particular OS.
- The reason for the above point is: Unlike other programming languages, output of Java compiler is not executable code, rather it is a Bytecode.
Now what is Bytecode? It is a highly optimized set of instructions designed to be executed by the Java Run-Time system.
- Java Run time System is called as JVM (Java Virtual Machine)
- JVM works as an interpreter for Bytecode (note in previous post, we read more about JVM, it is included in Java Run Time Environment)
Note: This Bytecode can execute on any platform, only JVM needs to be implemented on that platform. It’s because of this Bytecode only, why we call Java as a platform independent language.
Note: JVM for Linux, is not the same as of Windows or iOS.