Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

jvm

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

like image 736
Aaron Fi Avatar asked May 14 '09 03:05

Aaron Fi


People also ask

Is the JVM actually a virtual machine?

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode.

Does Java run on a virtual machine?

What is Java Virtual Machine (JVM)? Java Virtual Machine, or JVM, loads, verifies and executes Java bytecode. It is known as the interpreter or the core of Java programming language because it executes Java programming.

Is VMware and virtual machine same?

The most obvious distinction between the two is that VirtualBox is a free and open-source software programme whereas VMware is solely available for personal use. The free version of VMware for personal and educational use offers limited functionality. Clones and snapshots, for example, are not supported.

What file will be used by the Java Virtual Machine?

It loads the rt. jar file which contains all class files of Java Standard Edition like java. lang package classes, java.net package classes, java. util package classes, java.io package classes, java.


1 Answers

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).

like image 101
Eddie Avatar answered Oct 03 '22 08:10

Eddie