0

I am beginner and I have one doubt. I read in so many books that Java is platform independent, but JVM is platform dependent even I agree. Now, the question is: do all OS come with a JVM? I mean to say that in all OS JVM is already installed or not. Or when we install JDK then along with JDK JVM is also installed. If JVM is already installed and come with the OS then how can I check the existence of the JVM without installing JDK?

Please explain if anyone can. Thanks in Advance.

Martín Schonaker
  • 7,273
  • 4
  • 32
  • 55
Altaf Khan
  • 17
  • 4
  • Whether JVM is installed really depends on the OS. A basic Windows doesn't have one, but many OEM installations add it. Linux distros, it depends. Ubuntu has OpenJDK with JVM, for example, and you have to install Sun's JVM. To check if a JVM is installed, open a shell/console, and type `java -version`. – AntonH Dec 08 '14 at 04:10
  • A significant point is that Java is "Write once -- run anywhere". In order for a JVM to be "certified" it must run a test suite and produce the exact same results as occur on other Java systems. This means that the code you write in Java is "platform independent" -- so long as you don't intentionally include platform dependencies the code will run the same on any platform. And you don't need to recompile when moving it from one platform to another. – Hot Licks Dec 08 '14 at 04:16
  • 2
    A ton of languages are platform-independent. Sun just marketed it best. – Chris Martin Dec 08 '14 at 04:19

1 Answers1

3

The Java language is compiled into an intermediate format called byte-code (in contrast to earlier languages which are usually compiled into machine code for a single instruction set); the byte-code is interpreted by a Java Runtime Environment (or JRE). Some Operating Systems (but not all) ship with a JRE; and there is probably a JRE available for most Operating Systems (but again, not all).

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249