I would like to share a few things about the Java
programming language platform independency. It is going to be a basic discussion, so those of you who have had a good idea to Java may already know most of it. The intention of this BLOG is to give an idea to Java developers and others who are new to Java, a basic understanding about what platform independence in the Java world really means and how it is achieved.
Anyone working with Java would have also heard of it as a “Platform Independent” language. Is it really platform independent? When inquired with a couple of people who have worked with Java for quite sometime, the answer was something like this: “Well, in theory "yes", but in practice (?)”. Before we go to explore further about Java's platform independency, let us first understand what platform independence really means and how Java attempts to achieve it.
Platform independence, as the name suggests, is the ability of software to operate independently of the platform on which it is running. It means the software can run on any platform without re-compile. When you talk about Java as a platform independent language, it means that it can be developed and compiled on one platform and then run on any other platform. But the way in which every platform is architected and function are so different, then how is it possible for a code compiled at one platform to run on other platforms without re-compilation? The answer lies on the dependency of a Java application on the Java Virtual Machine.
The Java Virtual Machine is a platform specific program that understands how the Operating System works. You can consider the Java Virtual Machine as an interpreter who can translate the compiled Java byte codes to native calls that is understandable by the underlying Operating System. Since the Java Virtual Machine can translate the Java byte code to platform specific native calls, so you need Java byte code of your source and it doesn't matter on which platform Java code is compiled. Thus, Java has become platform independent. But that does not come without a price - although it has become “platform” independent, it has implicitly created another dependency - the dependency on the Java Virtual Machine.
Have you ever tried to run a Java application on a machine that does not have a Java Runtime Environment? What happens when you launch the application? It just won't start, no matter how simple the program is. That is because the Java Virtual Machine is a must to run Java applications without which you cannot run Java applications. Remember, Java Virtual Machine is platform specific. So what if tomorrow someone comes up with a platform for which no one has ever developed a Java Virtual Machine? How will you run Java applications on it? The answer is simple: You can't! But fortunately for us we have Java Virtual Machines for most of the popular Operating Systems. These Java Virtual Machines are even optimized and fine tuned in several ways to make the best out of it.
Now coming back to the question that triggered this discussion: “Is Java really platform independent?” In my experience I have had the opportunity to explore Java's platform independency on three popular Operating Systems - Linux, UNIX (HP) and Windows, and I really found it to be as independent as said to be.
It's a very good blog for java begineers.
Anuj