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.

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.