How Java Is Platform Independent?

How Java is Platform Independent?

How is the Java platform independent?

Platform independence refers to java compiled code (byte code) that can execute on any operating system.

A programme is written in a language that humans can understand. It could contain words, phrases, or other information the machine doesn’t understand. The source code must be written in a machine-readable language, usually a machine-level language, in order for the machine to understand it. As a result, a compiler is required. The compiler transforms the high-level language (human language) into a machine-readable format. As a result, a compiler is a programme that converts source code from one computer language to executable code for another. Join Java Training in Chennai to learn why java is platform-independent.

This executable code could be a set of machine instructions that the CPU can directly execute, or it could be an intermediate representation that a virtual machine interprets. The Java Byte Code is the intermediate representation in Java.

Step-by-step instructions Java Program Execution:

  • When a programme is created in JAVA, the javac compiler compiles it.
  • The JAVA compiler produces a.class file or bytecode rather than machine native code (unlike the C compiler).
  • The resulting bytecode is non-executable and requires an interpreter to run on a computer. The JVM is this interpreter, and it is the JVM that executes the Bytecode.
  • Finally, the programme executes to get the desired result.

why java is platform independent

The compiler outputs an.exe file that is OS dependent in the case of C/ C++ (languages that are not platform neutral). When we try to run this.exe file on a different OS, it fails since it is OS dependent and thus incompatible with the other OS. Java Online Training will enhance your programming skills in Java.

Although Java is platform-independent, the JVM is platform dependent.

The essential element to remember about Java is that the JVM depends on the operating system – thus, if you’re using Mac OS X, your JVM will be different than if you’re using Windows or another operating system. This fact may be verified by attempting to download the JVM for your specific machine – you will be presented with a list of JVMs corresponding to various operating systems, and you will obviously select the JVM that is aimed at the operating system you are using. As a result, we may deduce that JVM is platform-dependent, which is why Java is able to be “Platform Independent.”

Points to Remember:

  • In the case of Java, it’s Bytecode’s magic that makes it platform agnostic.
  • This contributes to a key aspect of the JAVA language known as portability. Every system has its own JVM installed when the Java Development Kit (JDK) is installed. There is a different JVM for each operating system that can read the. class file or byte code.
  • It’s worth noting that while JAVA is a platform-agnostic language, the JVM is platform-specific. Different JVMs are built for different operating systems, and byte code can execute on different operating systems.

Conclusion:

Here, in this blog, we have discussed why java is called platform independent and how it is independent. To learn more about the Java Platform, join Java Training in Coimbatore at FITA Academy.

Leave a Reply

Your email address will not be published. Required fields are marked *