Monday, May 30, 2016

How java is platform independent

How java is platform independent:

Java is a platform independent language, which means the java program can be executed on any platform in the world, whether it is a different architecture hardware / processor or different operating system like Linux / Unix, Macintosh, Windows etc.

Let’s discuss how it is achieved in java, let’s take a real example so that it will be easy to understand the platform in-dependency.

This is the scenario - I am an Indian and I have written a letter in Hindi language (Hindi is a national language of India), and obviously no one in the world knows Hindi language except Indians. Now, let’s assume that I have hired multiple agents who know Hindi and the native language for separate countries, for example I have hired an agent for America who knows Hindi and US English, an agent for China who knows Hindi and Chinese, an agent for France who knows Hindi and French, similarly for other countries as well.

Now, I have deputed all the agents in respective countries, and I am sending them the letters in Hindi language. Now, as we know all agents knows Hindi and their respective country languages, as soon as I do send the Hindi typed letter to them, they immediately read it very easily, convert it in their country specific language and convey the message to their citizens very easily. For example an American agent read letter in Hindi and convert it in English and convey message to American citizens, similarly for others. Here is the diagrammatic representation of above scenario:



In exactly similar way the java has implemented and ensured the platform in-dependency. Here we can assume the Hindi language as a Byte Code, and respective agents as Java Virtual Machines. The programmer writes program in high level language, then java compiler convert the program in byte code and generates the “.class” file, the .class is equivalent to Letter in Hindi Language,further the byte code is converted to machine understandable language by Java Virtual Machine which is equivalent to the respective Country Agents.

So, the complete java platform is a ensured platform in-dependency in this way, which can be executed in any hardware architecture or any operating system. We just need to install machine or OS specific JVM / JRE in order to execute the java byte code.

Now, let’s see the diagrammatic representation of java platform in-dependency:




No comments:

Post a Comment