mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-09 11:55:52 -04:00
Fixed finding Java problem with Windows XP.
This commit is contained in:
parent
1d915194c2
commit
798d933079
@ -3806,8 +3806,8 @@ org.jackhuang.hellominecraft.utils.system.Java -> org.jackhuang.hellominecraft.l
|
||||
51:54:boolean equals(java.lang.Object) -> equals
|
||||
59:59:int hashCode() -> hashCode
|
||||
64:78:java.util.List queryAllJavaHomeInWindowsByReg() -> a
|
||||
83:89:java.util.List queryRegSubFolders(java.lang.String) -> a
|
||||
93:100:java.lang.String queryRegValue(java.lang.String,java.lang.String) -> a
|
||||
83:90:java.util.List queryRegSubFolders(java.lang.String) -> a
|
||||
94:112:java.lang.String queryRegValue(java.lang.String,java.lang.String) -> a
|
||||
org.jackhuang.hellominecraft.utils.system.JavaProcess -> org.jackhuang.hellominecraft.launcher.ev:
|
||||
java.util.List commands -> a
|
||||
java.lang.Process process -> a
|
||||
|
@ -83,21 +83,33 @@ public class Java {
|
||||
String[] cmd = new String[]{"cmd", "/c", "reg", "query", location};
|
||||
List<String> l = IOUtils.readProcessByInputStream(cmd);
|
||||
List<String> ans = new ArrayList<>();
|
||||
for (String line : l)
|
||||
for (String line : l) {
|
||||
if (line.startsWith(location) && !line.equals(location))
|
||||
ans.add(line);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
private static String queryRegValue(String location, String name) throws IOException, InterruptedException {
|
||||
String[] cmd = new String[]{"cmd", "/c", "reg", "query", location, "/v", name};
|
||||
List<String> l = IOUtils.readProcessByInputStream(cmd);
|
||||
if (l.size() < 3) return null;
|
||||
// 18 = 4 spaces + [name.length()] + 4 spaces + "REG_SZ".length()=6 characters + 4 spaces
|
||||
String s = l.get(2);
|
||||
if (s != null && s.startsWith(" " + name + " REG_SZ "))
|
||||
return s.substring((" " + name + " REG_SZ ").length());
|
||||
else return null;
|
||||
boolean last = false;
|
||||
for(String s : l) {
|
||||
if(s.trim().isEmpty()) continue;
|
||||
if (last == true && s.trim().startsWith(name)) {
|
||||
int begins = s.indexOf(name);
|
||||
if(begins > 0) {
|
||||
s = s.substring(begins + name.length());
|
||||
begins = s.indexOf("REG_SZ");
|
||||
if(begins > 0) {
|
||||
s = s.substring(begins + "REG_SZ".length());
|
||||
return s.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(s.trim().equals(location)) last = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user