简体   繁体   中英

Using Runtime.exec to fork another instance of the current process

I'm trying to use Runtime.exec to start a copy of the current process. I am not necessarily interested in a fork because I don't need to share state. Is there a way I can determine the command used to start the current process and just re-run this?

如果在Linux上,您可以执行“ ps -eax”命令并为您的pid使用grep(不确定如何获取当前的vm pid)来获取启动您的vm的完整命令?

我最终从System.getProperty(“ java.class.path”)中提取了类路径,从而可以重新创建命令行参数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM