Java platform independent.what is a platform?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, April 7, 2003 09:13 PM

This question has been haunting me for a long time. When we say Java is platform independent,what does the term platform indicate? I think it is Processor+Operating System. But people talk only of Operating System as platform. A processor has its own instruction set that is different from that of other processors.An executable code on one processor doesn't run on another processor,whatever may be the operating system. Java code is platform independent because it is just compiled to byte code and that byte code is interpreted and run on a JVM.Here the JVM is different for different platforms. My question is: consider two platforms: Intel Pentium+MS Windows. and AMD At   More>>

This question has been haunting me for a long time.
When we say Java is platform independent,what does the term platform
indicate?

I think it is Processor+Operating System.

But people talk only of Operating System as platform.

A processor has its own instruction set that is different from that of other processors.An executable code on one processor doesn't run on another processor,whatever may be the operating system.

Java code is platform independent because it is just compiled to byte code and that byte code is interpreted and run on a JVM.Here the JVM is different for different platforms.
My question is:
consider two platforms:
Intel Pentium+MS Windows.
and AMD Athlon+MS Windows.
Is the same JVM used for both these platforms?or not?WHY?


If only Operating System is Considered as platform,what happens to the underlying processor?

   <<Less

Re: Java platform independent.what is a platform?

Posted By:   David_Bates  
Posted On:   Tuesday, April 8, 2003 01:48 AM

You've got a point. "Platform" is an over-used term, like "system". A few points:



"A processor has its own instruction set that is different from that of other processors.An executable code on one processor doesn't run on another processor,whatever may be the operating system."



Not quite true. You have families of processors e.g. x86, which allow for legacy code to be run.



"My question is: consider two platforms: Intel Pentium+MS Windows. and AMD Athlon+MS Windows. Is the same JVM used for both these platforms?"



Yes. You can see this if you download the JRE from Sun's website. HOWEVER, there would be nothing to stop you from writing an Athlon-optimised JVM (I'm sure people have done this).



The following diagram might help:



Java Byte Code -> Java Virtual Machine -> Operating System -> Processor



The Story: Java byte code is taken from the class files and fed into the vitual machine. The virtual machine then makes calls to the operating system to fulfill the behaviour of the virtual machine, as specified by Sun. The operating system then itself receives these calls, which are then mapped to calls to the processor. The way in which these operating system calls execute on the processor is dependent upon the operating system e.g. Hardware Abstraction Layer, Processor Optimizations etc.
About | Sitemap | Contact