How Java solves the problem of platform independent ?


In this tutorial we will discuss small information on how Java solves the problem of platform independent. Before seeing the solution as how its working we need to know answers for few questions like,

1. What is Java bytecode ?
2. What is machine code ?
3. What is JVM ?

Once we know about all these questions we can understand easily as how Java sloves this problem.


What is Java bytecode ?

      Each Java program which we write will be converted to bytecode by Java Compiler. From .java (Java program) to .class (Class file) file which contains byte codes. There are around 200 byte codes instructions which are used to covert any type of complex Java program to bytecodes files. Each byte codes instructions are of 8 bit which is 1 byte, hence its called Java bytecode.

What is Machine code?

     The lowest-level programming language is Machine languages and only the languages can understood by computers. Machine languages are impossible to understand by humans. Programmers will use high-level programming languages like (C, C++, Java, etc.,) are translated into machine language by a compiler. Every Operating System has its own unique machine language. Each high-level programs must be compiled to run on different types of computers.
For Example .exe file format is a machine language files where only Windows OS can understand and those files can't be executed in Mac or Linux etc.,

What id JVM?

     JVM is nothing but Java Virtual Machine. As the name indicates Virtual its not a real machine. Bytecodes compiled by compiler can be understand by any JVM and JVM used to convert the bytecode files to each machine code dependent files and executes the program. Where JVM are platform dependent and used to translate the bytecode into the machine language for a particular computer, and actually execute the corresponding machine-language instructions as well.

     Finally JVM are platform dependent and used to convert the byte code into corresponding platform machine languages. By this way Java solves the problem of platform independent.

Hope you are clear on how Java solves the platform independent problem. 

No comments:
Write comments