如何启动第二个 Java 进程? [英] How can I start a second Java process?

查看:78
本文介绍了如何启动第二个 Java 进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何启动第二个独立于平台的 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 上也有两个可执行文件;javajavaw.

  • The java executable is not necessarily called java and doesn't necessarily live in the bin subdirectory. Even with Sun Java, on Windows there are two executables; java and javaw.

对于不同的 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 使用 j9j9w 作为可执行文件名称.
  • BEA/Oracle JRockit有不同的 -X-XX 选项.
  • Jikes RVM 使用 rvm 作为可执行文件名,并且仅支持 Sun 的 java 选项的子集.
  • IKVM 使用 ikvm 作为可执行文件名.
  • IBM J9 uses j9 and j9w 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's java 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆