Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用 Runtime.exec 来启动当前进程的副本。我不一定对分叉感兴趣,因为我不需要共享状态。有没有办法可以确定用于启动当前进程的命令并重新运行它?
如果在 linux 上,也许您可以执行“ps -eax”命令并为您的 pid 执行 grep(不确定如何获取当前的 vm pid)以获取启动 vm 的完整命令?
我最终从 System.getProperty("java.class.path") 中提取了类路径,从而能够重新创建命令行参数。