Sunday 23 November 2014

Why Java is a platform independent language ?

Firstly we write our program (in java language) using notepad and other IDEs such as ecllipse  , netbeans . our computer does not know java language and other languages.

Then the question arises in our mind that

how computer runs our program and gives us the desired result . Answer is in our computer there is something called microprocessor which actually runs our program .But the problem is microprocessor knows only one language that is machine language ( a language consisting of 0's and 1's ) and different computers have different type of microprocessors inside them and different microprocessors understand different types of machine languages.So if we want to run our program then we have to convert our program in our computer's own machine language.Any programming language depends on microprocessors and operating system and there are many computers available in the market consists of different types of microprocessor and operating system .So the challenge is that we write our program in any language and it should run on all computers (computers with different configurations).Only there is java language that do that very easily .

Now we learn that how java does it . Firstly java compiler converts our source code into byte code and in every computer there is a program installed that is known as java virtual machine (JVM) .JVM is platform independent means computer with different microprocessor and operating system understands different machine language and JVM also understands byte code.So JVM converts bytecode into computer's own understandable machine language and computer just run it .Now we can say that JVM makes java a platform independent language.