Visit BlogAdda.com to discover Indian blogs Visit blogadda.com to discover Indian blogs Why java is platform independent : | Training Institute in Pune

Friday 2 February 2024

Why java is platform independent :

Java is platform-independent because it is compiled to a bytecode that can be run on any device that has a Java Virtual Machine (JVM). This means that you can write a Java program on one platform (such as Windows) and then run it on a different platform (such as macOS or Linux) without making any changes to the code.


When the Java program runs on any machine, then it is sent to the Java compiler where it converts it to byte code. Besides, this code is sent to JVM (Java Virtual Machine)that stays within the RAM of an OS. Thus, JVM identifies the platform that it’s running on and converts it into the native machine language. Therefore, we can say that this is a platform-independent programming language.



What is platform ?


Platforms are combinations of software and hardware that allow any program to run. It can run on any computer and any operating system too. These operating systems include Windows, Macs, Linux, etc. The program must also be converted into machine language by using a code so that it can run easily.


 Basically, a program is written in a high-level language (i.e. human-readable language) that includes many phrases, words, etc. And this cannot be understood by a machine in a general form. Therefore, it needs to be converted into a machine level language (MLL). The compiler makes it possible. Besides, the compiler is a kind of program that transforms the code from High-level (or coding language) to machine level language. This code or script can be a series of instructions that are directly performed by the CPU or can be sent to the JVM or Virtual Machine.


Moreover, when a program is developed and compiled within java or language, the code is directly transformed into MLL. This code or script is produced in the form of a .exe file. This produced .exe file can run only on a particular OS. This refers to when the program is compiled in Windows; the OS .exe file can run only in Windows OS. And it doesn’t run on other OS.





0 comments: