Why Java is “Platform Independent”?
Java works on the principle “Write Once , Run Anywhere”. Based on that principle, When an java application is compiled using Java Compiler, it consist of JVM (Java Virtual Machine) it converts the .java file into .class file. JVM contains all Java Components such as JRE(Java Runtime Environment) and other API’s. This JVM is Platform dependent, it is implemented as software in web browser or java technology development tool.
Now this .class file is called as Byte code. This byte code itself is enough to run the java application in any OS. This is not possible in c/c++ , because c/c++ won’t generate a Byte code/ .class and so it is run only on the machine where it is originated. Hence for this reason Java is said to be Patform Independent.
You are attending an international conference representing your country and you knows only one language let we take it as Hindi But all other in the Conference knows a Common Language English. So now you required a translator who knows Hindi and English to convey your thought among others for clear conversation.
Here, Representatives refers to Various Platforms, Translators refers to JVM, and English is Byte code Known to all Translators.