如何启动第二个 Java 进程? [英] How can I start a second Java process?
问题描述
如何启动第二个独立于平台的 Java 进程?理想情况下,它应该与当前运行的 Java 版本相同.是否有任何有用的系统属性?
How can I start a second Java process platform independent? Ideally it should be the same Java version that currently running. Are there any helpful system properties?
推荐答案
一般情况下是不可能的.
It is not possible, in general.
@khachik 的回答中提供的方法不一定适用于 Java 的非 Sun 实现.
The recipe provided in @khachik's answer will not necessarily work for a non Sun implementation of Java.
java 可执行文件不一定称为
java
,也不一定位于bin
子目录中.即使使用 Sun Java,在 Windows 上也有两个可执行文件;java
和javaw
.
The java executable is not necessarily called
java
and doesn't necessarily live in thebin
subdirectory. Even with Sun Java, on Windows there are two executables;java
andjavaw
.
对于不同的 Java 实现,启动 JVM 的命令的命令选项是不同的.所以 ProcessBuilder
步骤可能涉及不可移植的参数.
The command options for the command that starts a JVM are different for different Java implementations. So the ProcessBuilder
step may involve non-portable arguments.
虽然大多数 JVM 都采用了主要的 Sun java
命令选项,但仍有许多不同之处.例如:
While most JVMs have adopted the primary Sun java
command options, there are numerous differences. For example:
- IBM J9 使用
j9
和j9w
作为可执行文件名称. - BEA/Oracle JRockit有不同的
-X
和-XX
选项. - Jikes RVM 使用
rvm
作为可执行文件名,并且仅支持 Sun 的java
选项的子集. - IKVM 使用
ikvm
作为可执行文件名.
- IBM J9 uses
j9
andj9w
as the executable names. - BEA / Oracle JRockit has different
-X
and-XX
options. - Jikes RVM uses
rvm
as the executable name, and only supports a subset of Sun'sjava
options. - IKVM uses
ikvm
as the executable name.
(注意:这些只是在粗略阅读相应的在线文档时脱颖而出的例子.)
(Note: these are just examples that stand out in a cursory reading of the respective online documentation.)
这篇关于如何启动第二个 Java 进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!