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

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

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

問題描述

限時送ChatGPT賬號..

這是我自己以前的問題的后續(xù)行動,我有點不好意思問這個......但無論如何:您將如何以獨立于系統(tǒng)的方式從獨立的 Java 程序啟動第二個 JVM?并且不依賴于例如像 JAVA_HOME 這樣的環(huán)境變量,因為它可能指向與當(dāng)前運行的 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();
}

此外,當(dāng)前正在運行的 JVM 可能已使用第二個 JVM 不知道的其他一些參數(shù)(-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.

推薦答案

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

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.

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

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.

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

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.

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

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

相關(guān)文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉(zhuǎn)換為公歷?)
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 日之前日期的日歷到日期轉(zhuǎn)換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當(dāng)前星期幾的值)
主站蜘蛛池模板: 欧美日本一区二区 | 99精品视频一区二区三区 | 成人福利在线观看 | 在线精品一区 | 中文字幕在线电影观看 | 欧美片网站免费 | 精品中文在线 | 国产不卡一区 | 欧美在线播放一区 | 亚洲乱码国产乱码精品精的特点 | 久久精品男人的天堂 | 亚洲va欧美va天堂v国产综合 | 激情av在线 | 亚洲av毛片 | av在线免费观看网站 | 久久亚洲精品视频 | 欧美在线天堂 | 久久久精品天堂 | 久久一区二 | 久久精品亚洲精品国产欧美 | 成人精品一区亚洲午夜久久久 | 99福利在线观看 | 波多野结衣在线观看一区二区三区 | 一区二区三区在线看 | 日日骚网 | 欧美日韩一区二区三区四区 | 国产重口老太伦 | 欧美色欧美亚洲另类七区 | 久久久久国产一区二区三区 | 日本电影韩国电影免费观看 | 中文字幕在线播放第一页 | 蜜臀91视频 | 欧美激情综合 | 久久精品网 | www国产精品 | 超级碰在线 | 视频一区二区在线 | 精品一二三区视频 | 91精品一区二区三区久久久久 | 人人人人干 | 亚洲美女天堂网 |