Java and Platform Independency

Embed Size (px)

Citation preview

  • 8/2/2019 Java and Platform Independency

    1/3

    freeze-cse.blogspot.com

    Java and Platform Independency

    Fareez Ahamed K.N.

    [email protected]

    Necessity is the mother of invention. Computer languages are not an exception to this

    rule. However, there are as many as 1600 different computer languages as they say. Did

    all these languages have necessities? Yes. But the importance of the necessities differ. At

    the least it had a necessity to satisfy its own designer. When a language satisfies a big

    need of numerous people, it remains, others wash away or limited to particular

    community. Java is one such language which was designed for something and outgrown

    into something invincible.

    C++ was almost a perfect object oriented language. So Javas objective is not a more

    perfect OO Language. The issue that caused Java to originate is the variety of

    microprocessors that started to emerge at that time. Previous languages were platform

    specific. For each platform you have to code a little different from the others. Javawanted to address this problem. Green team of Sun Microsystems wanted to create Java

    as a platform independent language. By doing so, Java can incorporate itself into any

    embedded system, making the development of embedded system easy and portable as

    well.

    But is that possible? Till then the most successful languages were using compiler to

    convert them into object codes that are executable in a particular platform. So to make

    platform independency possible, they have to change this methodology itself and they

    indeed did that to achieve platform independency which is why we call Java a technology

    rather than a language.

    Java is compiled and interpreted. It may sound strange. Till the advent of Java, a

    language is either compiled or interpreted but not both. Why this new method was

    brought in? A variety of microprocessors started to emerge and each one had its own

    machine language. Moreover they had different length of registers to store the data as

    well. If you compile your program into a particular machine language it will not be

    supported by other machines. So the green team decided to compile Java programs into a

    common machine language named Bytecode. Bytecode cannot be run by the

    microprocessors directly as no microprocessor knows that language. Hence we need an

    interpreter to interpret Bytecode into the local machine language. They brought the

    concept of virtual machine to achieve this. Java Virtual Machine is a system software that

    can understand the bytecode and interpret it to the lower level machine. Responsibilitiesof the JVM are a lot more than an interpreter which is out of scope of over topic.

  • 8/2/2019 Java and Platform Independency

    2/3

    freeze-cse.blogspot.com

    Fig 1. Compile and Run Methodology

    The above picture represents the traditional compile and run technique. There are two

    platforms A and B ( Call it Pulse and Sawtooth ). An application which is compiled for

    Platform A cannot fit the environment of Platform B. Thus its not platform independent,

    and you have to adjust your program for the new Platform.

    Fig 2. Java's Methodology

    Java overcomes the problem with the above model. Java applications are not compiled to

    any specific platform. They are compiled to the Bytecode which will be interpreted by

    JVM to the underlying platform. One more thing to notice is, JVMs have to be

    implemented for each platform to run Bytecode on that platform. This indeed is an issue.

    But Sun Microsystems made the Java Virtual Machine Specification available to

    everyone with which the JVM can be implemented to any platform easily. JVM

    Specification and Java language is designed simpler in order to make the JVM

    implementation simpler. It can be implemented to a minimum size of 680 KB! So that it

    can run on smaller chips and cell phones.

    When Java came into picture, internet has started to spread tremendously. Internet is a

    network of different platforms, so Java being platform independent found itself easy to

    become the prime technology for web.

    This alone is not the success of Java. Though C++ has all the object oriented features,

    Java wanted to make it simple and unambiguous. It removed all the confusing,

    unambiguous and non-productive features from C++, making it the simplest

    implementation of best OO features.

  • 8/2/2019 Java and Platform Independency

    3/3

    freeze-cse.blogspot.com

    Java runs in PCs, mobile phones, set top boxes, smart cards, robots and everywhere. Java

    developers are the largest in numbers. Be proud to be a Java developer. Enjoy developing

    without limits.