Home » Java programming language

Why java is platform independent?



Learn: why java is platform independent? What do you understand by platform independent? How java is platform independent?
Submitted by Preeti Jain, on February 03, 2018

Since, we know that "Java is a platform independent language". First we will understand what is platform independency?

When we write a program (or code) on one operating system (or platform) and execute on another operating system like Linux or UNIX. We will get the same result, when we execute a program there is no affect in output.

Why java is platform independent ?

  • How java is platform independent just because of Bytecode (i.e. Bytecode is the machine understandable code of the JVM (Java Virtual Machine) )
  • By using Bytecode execution java proves it is a platform independent language.
    Here, is the process of java bytecode execution.
    sample.java → javac (sample. class) → JVM(sample.obj) → display final output.
  • First source code is used by java compiler and converted that code in .class file and the class file code is in byte code form and that class file is used by JVM and again to convert into object file and then after display final output on the screen.
  • Java is platform independent language (In simple terms we can run (.class file) on any platform. Behavior will be same (on MAC, LINUX, and WINDOWS)).
  • Java compiler converts source code to bytecode and bytecode is not designed for a specific operating system understandable.
  • JVM reads bytecode and translate bytecode to specific operating system understandable form.
  • Bytecode are also known as JVM understandable code or intermediate code.
  • Java communicates with JVM and JVM communicates with byte code.
  • If Bytecode exists then JVM will read and if not exist then JVM will raise exception.





Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.



Comments and Discussions


We are using Google to publish ads on our website; Google has its own privacy policies. They may save log, cookies on your system. Google may also collect information of your system like IP address, region, city, country. For more details please go through the Google’s privacy policy.