Why we called Java as Platform Independent?

Before starting why we called Java as platform independent I want to share a simple incident with you and understand the Java compilation process in terms of that story.


Say Narendra Modi our respected PM giving a speech in Hindi, Next day in every news daily irrespective of language(Hindi, English, Bengali) this speech is published. Now the question is Narendra Modi give that speech in Hindi so how it translates to English or Bengali seamlessly.


No surprise right, there are reporters for every newspaper they analysis that speech and transform it to another language like English or Bengali.


So I can say theoretically Modi's speech is Language independent as next day everyone sees it in their respective languages.


Java, Does it the same way, It takes your code as input like Modi's live speech and there is Java interpreter which is platform dependent, for Linux, Java provides Linux interpreter for Windows a Windows interpreter, Whose task it taking that input and transform it to Machine code the language OS understand. SO it is like the reporters who translate Modi's speech to respective language.

Now coming to Technical part. 


Actually, to be specific Java compilation is a two-step process Compile then Run Compiler makes the byte code and JVM inter-prate this to machine specific language Here is the trick  I am taking about , Might you have seen when you download JDK there is OS specific version  one is for Unix one is for windows version why so, because  of JVM implementation JVM takes bytecode as input and provide m/c language as output so Linux specific JVM makes Linux specific machine code, windows do the same but as both take bytecode as input you can easily export Windows compile class  Linux m/c That's why they called Java as a platform independent .