Wednesday, September 28, 2011

JAVA BASICS.. JAVA A DIFFERENT APPROACH TO START.. JAVA PLATFORM INDEPENDENT. HOW JAVA IS PORTABLE?


Must read for a good start of JAVA

All of us know that JAVA is portable i.e JAVA is platform independent.Let us try to figure out the reason how Java is platform independent. Java has used a slogan Write Once Run anywhere.

Explanation:
Some language generate .obj or .exe file after compiling. These generated file will not work in other Operating system. There was a need to have something which will not depend on operating system. Hence they came with new concept of JAVA VIRTUAL MACHINE(JVM). Running a java program was divided into 2 parts. First part makes .class file and in the second part this .class file will be run on JVM.
For the generation of .class file from .java file,compiler was written which will always generate the same .class file for any of the operating systems. Half of the work is over for getting platform independency.

.java ----Compile---->.class(Byte Code)---Interpreter(Platform Dependent)--->machineCode


For running the same .class file in different OS, they made a difference in JVM for different operating system. JVM depends on the hardware and OS architecture. It will take .class file as input and interpret it. So for the same .class file it will generate the same output. It is the difference in JVM which has made java a platform independent language.

Now in the next post we will learn basics of java taking memory into consideration.

1 comment:

  1. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.

    ReplyDelete