久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

*this* 真的是從 Java 代碼啟動第二個 JVM 的最佳方

Is *this* really the best way to start a second JVM from Java code?(*this* 真的是從 Java 代碼啟動第二個 JVM 的最佳方式嗎?)
本文介紹了*this* 真的是從 Java 代碼啟動第二個 JVM 的最佳方式嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

這是我自己以前的問題的后續行動,我有點不好意思問這個......但無論如何:您將如何以獨立于系統的方式從獨立的 Java 程序啟動第二個 JVM?并且不依賴于例如像 JAVA_HOME 這樣的環境變量,因為它可能指向與當前運行的 JRE 不同的 JRE.我想出了以下代碼,它確實有效,但感覺有點尷尬:

This is a followup to my own previous question and I'm kind of embarassed to ask this... But anyway: how would you start a second JVM from a standalone Java program in a system-independent way? And without relying on for instance an env variable like JAVA_HOME as that might point to a different JRE than the one that is currently running. I came up with the following code which actually works but feels just a little awkward:

public static void startSecondJVM() throws Exception {
    String separator = System.getProperty("file.separator");
    String classpath = System.getProperty("java.class.path");
    String path = System.getProperty("java.home")
                + separator + "bin" + separator + "java";
    ProcessBuilder processBuilder = 
                new ProcessBuilder(path, "-cp", 
                classpath, 
                AnotherClassWithMainMethod.class.getName());
    Process process = processBuilder.start();
    process.waitFor();
}

此外,當前正在運行的 JVM 可能已使用第二個 JVM 不知道的其他一些參數(-D、-X...、...)啟動.

Also, the currently running JVM might have been started with some other parameters (-D, -X..., ...) that the second JVM would not know about.

推薦答案

我不清楚你是否總是希望使用完全相同的參數、類路徑或其他任何東西(尤其是 -X 類型的東西 - 例如,為什么要啟動輔助進程時,子進程需要與其父進程相同的堆設置.

It's not clear to me that you would always want to use exactly the same parameters, classpath or whatever (especially -X kind of stuff - for example, why would the child need the same heap settings as its parents) when starting a secondary process.

我更愿意使用某種外部配置來為孩子定義這些屬性.這需要更多的工作,但我認為最終你將需要靈活性.

I would prefer to use an external configuration of some sort to define these properties for the children. It's a bit more work, but I think in the end you will need the flexibility.

要查看可能的配置設置范圍,您可以查看 Eclipse 中的運行配置"設置.那里有相當多的選項卡值得配置.

To see the extent of possible configuration settings you might look at thye "Run Configurations" settings in Eclipse. Quite a few tabs worth of configuration there.

這篇關于*this* 真的是從 Java 代碼啟動第二個 JVM 的最佳方式嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 色就干| 午夜a区 | 91精品久久 | 播放一级黄色片 | 亚洲精品成人网 | 一区二区av | 九九热免费在线观看 | 欧美日韩视频在线播放 | 日本免费一区二区三区四区 | 黄色一级大片在线免费看产 | 亚洲视频在线看 | 国产综合av| 99热在线免费 | 日韩欧美一区二区三区免费观看 | 日韩一二三区视频 | 色婷婷影院| www.国产91 | 久久99精品久久久 | 日本午夜精品一区二区三区 | 亚洲成人网在线观看 | 国产一区二区三区色淫影院 | 欧美久久久久久久久 | 91国内精精品久久久久久婷婷 | 国产精品成人国产乱一区 | 国产美女视频黄a视频免费 国产精品福利视频 | 视频二区 | 欧美日韩国产在线观看 | 狠狠伊人| 人人擦人人干 | 日韩在线一区视频 | 国产免费a视频 | 一区二区三区不卡视频 | 久久综合一区二区三区 | 国产黄色大片 | 91成人精品 | 少妇淫片aaaaa毛片叫床爽 | 久久看精品 | 亚洲国产一区二区三区在线观看 | 日本在线看 | 欧美性tv | 久久久美女 |