且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在单独的进程中执行Java应用程序

更新时间:2023-08-17 14:46:04

两个提示:

System.getProperty(java.home)+/ bin / java为您提供java可执行文件的路径。

System.getProperty("java.home") + "/bin/java" gives you a path to the java executable.

((URLClassLoader)Thread.currentThread()。getContextClassLoader())。getURL()帮助您重建当前应用程序的类路径。

((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURL() helps you to reconstruct the classpath of current application.

然后你的 EXECUTE.application 只是(伪代码):

Then your EXECUTE.application is just (pseudocode):

Process.exec(javaExecutable, - classpath,urls.join(:),CLASS_TO_BE_EXECUTED)