Why Java is Platform Independent

Why Java is Platform Independent

Java Online TrainingPlatform independent means, the java compiled program can be run on any operating system. Java is platform independent because it converts the given source code into byte code. Every operating system has its own byte code so the java is platform independent.

One of the key reasons Java technology is useful in a networked environment is that Java makes it possible to create binary executables that will run unchanged on multiple platforms. This is important in a networked environment because networks usually interconnect many different kinds of computers and devices.

The Java code that you compile gets converted to a form known a byte code that is present in the .class files. Every OS has its own JVM. The JVM takes this byte code and then executes the program. So the hardware dependency is taken care of by the JVM. Hence Java is platform Independent.

A Java program never really executes natively on the host machine. Rather a special native program called the Java interpreter reads the byte code and executes the corresponding native machine instructions. Thus to port Java programs to a new platform, all that is needed is to port the interpreter and some of the library routines. Even the compiler is written in Java. The byte codes are precisely defined, and remain the same on all platforms.

When you write the program for any programming language it is called (source program), and it will have the extension depending upon the language. In Java, when you write the program, you will have the “.java” file. And when it is compiled, you will get the “.class” file. The “.class” file is executed by the Java Virtual Machine (JVM). If you have the JVM, you can execute the java program anywhere under operating system. That means, Java is Platform Independent.

Java is platform independent due to the concept of J.I.T after compilation of java source code file name. class file prepared by the J.V.M is called byte code but j.v.m is platform dependent that byte code is further interpreted by J.I.T in the machine code by this process java becomes platform independent.

A Java language is platform independent since it satisfies the following 3 conditions:

1. It is compiled in a platform neutral manner i.e. object code obtained after compilation doesn’t contain any Operating System specific information and doesn’t follow O.S. specification formats.

2. Language provides its own runtime environment for execution of its applications.

3. Language provides comprehensive library to act as an interface for O.S. services i.e. applications developed in the language doesn’t directly reference any O.S. specific functionality.

For Java Online Training please visit http://www.revanthtechnologies.com