[FIX] JavaHelper Windows

This commit is contained in:
Gravita 2021-07-09 17:18:29 +07:00
parent 736aa93106
commit 0cc47a7b06
3 changed files with 16 additions and 3 deletions

View file

@ -177,8 +177,7 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
authManager = new AuthManager(this); authManager = new AuthManager(this);
updatesManager = new UpdatesManager(this); updatesManager = new UpdatesManager(this);
RestoreResponse.registerProviders(this); RestoreResponse.registerProviders(this);
//Generate or set new Certificate API
certificateManager.orgName = config.projectName;
config.init(ReloadType.FULL); config.init(ReloadType.FULL);
registerObject("launchServer", this); registerObject("launchServer", this);
GarbageManager.registerNeedGC(sessionManager); GarbageManager.registerNeedGC(sessionManager);

View file

@ -137,6 +137,20 @@ public static String getIP(SocketAddress address) {
return ((InetSocketAddress) address).getAddress().getHostAddress(); return ((InetSocketAddress) address).getAddress().getHostAddress();
} }
public static Path getRoot() {
switch (JVMHelper.OS_TYPE) {
case MUSTDIE: {
String drive = System.getenv("SystemDrive");
return Paths.get(drive);
}
case LINUX:
case MACOSX: {
return Paths.get("/");
}
}
throw new UnsupportedOperationException();
}
public static byte[] getResourceBytes(String name) throws IOException { public static byte[] getResourceBytes(String name) throws IOException {
return read(getResourceURL(name)); return read(getResourceURL(name));
} }

View file

@ -78,7 +78,7 @@ public static List<JavaVersion> findJava() {
} }
} }
if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) { if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) {
Path rootDrive = Paths.get(System.getProperty("java.home")); Path rootDrive = IOHelper.getRoot();
try { try {
trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("Java")); trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("Java"));
trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("AdoptOpenJDK")); trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("AdoptOpenJDK"));