wood burning stoves*
The moose likes Beginning Java and the fly likes JVM-platform dependent or indepenedent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JVM-platform dependent or indepenedent" Watch "JVM-platform dependent or indepenedent" New topic
Author

JVM-platform dependent or indepenedent

pri mish
Greenhorn

Joined: May 21, 2007
Posts: 2
Hi,

This seems to be one big tricky question,atleast the info on the net is anything to go by.

Like for JAVA language,we can say that its platform independent.

How abt JVM?is it dependent or independent of the platform?
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Not very tricky at all, really, unless you want to get bogged down in minute details.

The Basic Story

Java programs run on one platform only: the Java Virtual Machine (JVM). By targetting the JVM, rather than the underlying Operating System (OS), Java is said to be independent of the OS platform.

The JVM is typically a program that runs on the native architecture of the OS. Therefore, the executables and libraries that make up the JVM are dependent on the OS platform.

Some of the Complications

The Java libraries (java.* packages) contain a few methods that are "native". These methods are typically implemented in C or C++ and come in libraries that are dependent on the OS platform.

Some Java applications need to access OS features that are not exposed by the Java libraries or JVM. They do this by implementing their own "native" methods through JNI. Again, this results in libraries that are dependent on the OS platform.

While the Java libraries make it possible for a careful programmer, writing in pure Java (no native code), to "abstract away" most platform differences, sometimes this is not 100% successful. Very occasionally, a pure Java program has to test what OS it is running on, via System.getProperty(). This should always be considered a last resort, done only after checking carefully that there is no other way.

If currently writing and running your Java code on only one platform, you should take care not to inadvertently hard-code features of that platform. For instance, if running on Windows, don't hard-code back-slashes into file paths etc.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
Java itself is platform independent (or close to it). Each JVM is platform dependent. There are a number of dependency issues, in fact. There are vendor, version, and OS dependencies associated with each JVM implementation. You can read more at http://www.ibm.com/developerworks/java/library/j-diag0521.html
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
Java itself is platform independent (or close to it). Each JVM is platform dependent. There are a number of dependency issues, in fact. There are vendor, version, and OS dependencies associated with each JVM implementation. You can read more at http://www.ibm.com/developerworks/java/library/j-diag0521.html
pri mish
Greenhorn

Joined: May 21, 2007
Posts: 2
Hi,

thanks a lot for the deep explanation. I did read somewhere abt the way a JVM uses the Host Porting Interface(HPI) for making an abstraction layer from the target operating system is the reason for its dependence on the underlying platform.

Please confirm.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JVM-platform dependent or indepenedent
 
Similar Threads
Java Compiler and JVM are platform dependent or independent?
Java Compiler and JVM are platform dependent or independent?
platform-independent
About JVM
Java Compiler and JVM are platform dependent or independent?