tags:

views:

278

answers:

3

Is the Java Virtual Machine really a virtual machine in the same sense as my VMWare or Parallels file?

+4  A: 

No. There is a difference between system virtual machine and process virtual machine. JVM is a process virtual machine, whereas the VMWare and the kind are system virtual machines. For more please refer to the wikipedia entry.

As far as parallel virtual machines are concern, the above mentioned entry states,

PVM (Parallel Virtual Machine) are not strictly virtual machines, as the applications running on top still have access to all OS services, and are therefore not confined to the system model provided by the "VM".

Adeel Ansari
+7  A: 

No.

VMWare and the rest actually virtualize the hardware of the machine. The operating system running inside of a VMWare container (or Parallels or Windows' virtualization containers or Bochs or ...) have varying degrees of awareness of running within a virtualized container. Within VMWare, the operating system has no idea that it is running within a virtual container. The operating system is not modified at all, although specialized drivers are usually installed (most importantly video) to prevent performance problems. Some other VM's don't do full hardware virtualization and instead require the OS inside the container the make special calls to the container in place of the regular hardware calls.

The JVM is not a virtual machine in that sense at all. No hardware other than the processor is virtualized. The JVM is essentially a virtualized CPU plus the same sort of runtime that is included with a C++ or any other object oriented language, plus garbage collection and other necessities. Additionally, of course, Java class files (and JAR files, etc) are not machine code, but an intermediate byte code. So the JVM has to compile or interpret class files (whether contained in a JAR file or not) at runtime, and has the ability to load and find new code dynamically at runtime.

The JVM is called a virtual machine because the JVM definition defines an abstract machine. This includes registers, stack, etc, and the byte code that Java source is compiled to is practically machine code for this virtual machine. The JVM then interprets or compiles this byte code into native machine instructions.

The difference is essentially that the JVM is a virtualized processor and the other virtual machines are virtualized machines (including video card, network, and other external devices and hardware registers).

Eddie
A: 

There's a decent summary of the distinctions in "Running Xen: A Hands-On Guide to the Art of Virtualization" by Jeanna Matthews, et al. (Amazon). VMWare is an example of full virtualization, and seeks to virtualize a physical hardware architecture so that different unmodified guest operating systems can sit on it. A Java Virtual Machine is an example of what they call application virtualization, where "Applications run in a virtual execution environment that provides a standard API for cross-platform execution and manages the application's consumption of local resources." (p. 13)

In both cases you have a virtualization layer that software runs on top of. The JVM runs Java applications, while VMWare runs full operating systems. VMWare virtualizes a machine that used to always be expressed as physical hardware. A JVM virtualizes a machine that could be expressed in physical hardware, but almost always isn't (but see hardware JVMs).

Jim Ferrans