java 如何启动 jvm,我们可以在单个系统上运行多个 jvm 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37298011/
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
how to start jvm and can we have multiple jvm running on a single system?
提问by Dhanshree More
I had been asked this question in interview, how to start jvm and can we have multiple jvm running on a single system?
我在面试中被问到这个问题,如何启动 jvm,我们可以在一个系统上运行多个 jvm 吗?
回答by Ankur Singhal
Each Java application running uses an independent JVM.
每个运行的 Java 应用程序都使用一个独立的 JVM。
Each JVM is a separate process, and they do not share stacks, heaps. Only common core JVM and native libraries will be shared.
每个 JVM 都是一个单独的进程,它们不共享堆栈、堆。只会共享通用的核心 JVM 和本机库。
You can have n number of application running on single machine/server box, and so as n number of JVM's.
您可以在单台机器/服务器上运行 n 个应用程序,以及 n 个 JVM。
Launching multiple java processes will create JVM for you.
启动多个 java 进程将为您创建 JVM。
In all you can have any number of JVM running in your machine, with even different JDK versions.
总之,您的机器上可以运行任意数量的 JVM,甚至可以使用不同的 JDK 版本。
回答by Stephen C
How to start jvm.
如何启动 jvm。
If you have a Java JRE or JDK, then the simple way to start a JVM is to run the java
command. For example:
如果您有 Java JRE 或 JDK,那么启动 JVM 的简单方法是运行java
命令。例如:
java -jar someapp.jar
starts a JVM that runs the application in the supplied ("executable") JAR file.
启动一个 JVM,该 JVM 在提供的(“可执行的”)JAR 文件中运行应用程序。
Can we have multiple jvm running on a single system?
我们可以在单个系统上运行多个 jvm 吗?
Yes. Provided you have enough memory.
是的。只要你有足够的内存。
On a typical OS, each JVM runs as a process. Assuming that the OS allows you to launch multiple processes, you can run multiple JVMs. (This is certainly true for Windows, Linux, MacOSX and other varieties of UNIX on which Java runs.)
在典型的操作系统上,每个 JVM 都作为一个进程运行。假设操作系统允许您启动多个进程,您可以运行多个 JVM。(对于运行 Java 的 Windows、Linux、MacOSX 和其他种类的 UNIX,这当然是正确的。)