Java 虚拟机真的是与我的 VMWare 或 Parallels 文件具有相同意义的虚拟机吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/861422/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is the Java Virtual Machine really a virtual machine in the same sense as my VMWare or Parallels file?
提问by Aaron Fi
Is the Java Virtual Machine really a virtual machine in the same sense as my VMWare or Parallels file?
Java 虚拟机真的是与我的 VMWare 或 Parallels 文件具有相同意义的虚拟机吗?
回答by Eddie
No.
不。
VMWare and the rest actually virtualize the hardwareof 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.
VMWare 和其余的实际上虚拟化了机器的硬件。在 VMWare 容器(或 Parallels 或 Windows 的虚拟化容器或 Bochs 或...)内运行的操作系统对在虚拟化容器内运行有不同程度的认识。在 VMWare 中,操作系统不知道它正在虚拟容器中运行。尽管通常安装了专门的驱动程序(最重要的是视频)以防止性能问题,但操作系统根本没有修改。其他一些 VM 不进行完整的硬件虚拟化,而是要求容器内的操作系统对容器进行特殊调用,而不是常规硬件调用。
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.
从这个意义上说,JVM 根本不是虚拟机。除了处理器之外,没有其他硬件被虚拟化。JVM 本质上是一个虚拟化的 CPU,加上 C++ 或任何其他面向对象语言中包含的相同类型的运行时,加上垃圾收集和其他必需品。此外,当然,Java 类文件(和 JAR 文件等)不是机器码,而是中间字节码。因此,JVM 必须在运行时编译或解释类文件(无论是否包含在 JAR 文件中),并且具有在运行时动态加载和查找新代码的能力。
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.
JVM 之所以称为虚拟机,是因为 JVM 定义定义了一个抽象机。这包括寄存器、堆栈等,Java 源代码编译成的字节码实际上是该虚拟机的机器码。然后 JVM 将此字节码解释或编译为本地机器指令。
The difference is essentially that the JVM is a virtualized processorand the other virtual machines are virtualized machines(including video card, network, and other external devices and hardware registers).
区别本质上是JVM是一个虚拟化的处理器,其他的虚拟机都是虚拟化的机器(包括显卡、网络等外部设备和硬件寄存器)。
回答by Adeel Ansari
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.
不可以。系统虚拟机和进程虚拟机是有区别的。JVM 是进程虚拟机,而 VMWare 和 kind 是系统虚拟机。有关更多信息,请参阅维基百科条目。
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".
PVM(并行虚拟机)并不是严格意义上的虚拟机,因为运行在顶部的应用程序仍然可以访问所有操作系统服务,因此不受“VM”提供的系统模型的限制。
回答by Jim Ferrans
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)
Jeanna Matthews 等人在“运行 Xen:虚拟化艺术实践指南”中对这些区别进行了不错的总结。(亚马逊)。VMWare 是完全虚拟化的一个例子,它试图虚拟化一个物理硬件架构,以便不同的未经修改的客户操作系统可以坐在它上面。Java 虚拟机是他们所谓的应用程序虚拟化的一个例子,其中“应用程序在虚拟执行环境中运行,该环境为跨平台执行提供标准 API 并管理应用程序对本地资源的消耗。” (第 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 couldbe expressed in physical hardware, but almost always isn't (but see hardware JVMs).
在这两种情况下,您都有一个软件在其上运行的虚拟化层。JVM 运行 Java 应用程序,而 VMWare 运行完整的操作系统。VMWare 虚拟化了过去总是表示为物理硬件的机器。JVM 虚拟化了一台可以用物理硬件表示的机器,但几乎总是不是(但请参阅硬件 JVM)。

