Why java is platform independent?

Learn: why java is platform independent? What do you understand by platform independent? How java is platform independent? By Preeti Jain Last updated : January 02, 2024

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

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?

The following are the features that make Java platform an independent language -

  • 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.

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.