This commit is contained in:
huangyuhui
2016-02-23 20:32:24 +08:00
parent 7c3159fc23
commit 770ec3ab97
21 changed files with 215 additions and 116 deletions

View File

@@ -92,8 +92,9 @@ public class Java {
*/
public static List<Java> queryAllJDKInMac() {
List<Java> ans = new ArrayList<>();
if (new File("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home").exists())
ans.add(new Java("JRE", "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"));
File jre = new File("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home");
if (jre.exists())
ans.add(new Java("JRE", jre.getPath()));
File f = new File("/Library/Java/JavaVirtualMachines/");
if (f.exists())
for (File a : f.listFiles())
@@ -109,36 +110,28 @@ public class Java {
public static List<Java> queryAllJavaHomeInWindowsByReg() {
List<Java> ans = new ArrayList<>();
try {
List<String> javas = queryRegSubFolders("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment");
for (String java : javas) {
int s = 0;
for (char c : java.toCharArray())
if (c == '.')
s++;
if (s <= 1)
continue;
String javahome = queryRegValue(java, "JavaHome");
if (javahome != null)
ans.add(new Java(java.substring("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\".length()), javahome));
}
javas = queryRegSubFolders("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit");
for (String java : javas) {
int s = 0;
for (char c : java.toCharArray())
if (c == '.')
s++;
if (s <= 1)
continue;
String javahome = queryRegValue(java, "JavaHome");
if (javahome != null)
ans.add(new Java(java.substring("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\".length()), javahome));
}
queryJava(ans, "HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment");
queryJava(ans, "HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit");
} catch (IOException | InterruptedException ex) {
HMCLog.err("Faield to query java", ex);
}
return ans;
}
private static void queryJava(List<Java> ans, String location) throws IOException, InterruptedException {
for (String java : queryRegSubFolders(location)) {
int s = 0;
for (char c : java.toCharArray())
if (c == '.')
++s;
if (s <= 1)
continue;
String javahome = queryRegValue(java, "JavaHome");
if (javahome != null)
ans.add(new Java(java.substring(location.length()), javahome));
}
}
private static List<String> queryRegSubFolders(String location) throws IOException, InterruptedException {
String[] cmd = new String[] { "cmd", "/c", "reg", "query", location };
List<String> l = IOUtils.readProcessByInputStream(cmd);

View File

@@ -19,6 +19,7 @@ package org.jackhuang.hellominecraft.util.ui;
import java.awt.Frame;
import java.awt.HeadlessException;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.List;
@@ -38,35 +39,11 @@ public class WebFrame extends JFrame {
}
public WebFrame(String content) throws HeadlessException {
addWindowListener(new WindowListener() {
@Override
public void windowOpened(WindowEvent e) {
}
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
SwingUtils.exitIfNoWindow(WebFrame.this);
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
});
add(new WebPage(content));

View File

@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=未能解压游戏本地库,还要
launch.wrong_javadir=错误的Java路径将自动重置为默认Java路径。
launch.exited_abnormally=游戏非正常退出,请查看日志文件,或联系他人寻求帮助。
launch.state.logging_in=登录中
launch.state.generating_launching_codes=正在生成启动代码
launch.state.downloading_libraries=正在下载必要文件
launch.state.decompressing_natives=正在释放本地文件
install.no_version=未找到要安装的对应MC版本
install.no_version_if_intall=未找到要安装的对应MC版本是否自动安装需要的MC版本
install.not_refreshed=未刷新列表

View File

@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=\u672a\u80fd\u89e3\u538b\u6e38\u620f\u
launch.wrong_javadir=\u9519\u8bef\u7684Java\u8def\u5f84\uff0c\u5c06\u81ea\u52a8\u91cd\u7f6e\u4e3a\u9ed8\u8ba4Java\u8def\u5f84\u3002
launch.exited_abnormally=\u6e38\u620f\u975e\u6b63\u5e38\u9000\u51fa\uff0c\u8bf7\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\uff0c\u6216\u8054\u7cfb\u4ed6\u4eba\u5bfb\u6c42\u5e2e\u52a9\u3002
launch.state.logging_in=\u767b\u5f55\u4e2d
launch.state.generating_launching_codes=\u6b63\u5728\u751f\u6210\u542f\u52a8\u4ee3\u7801
launch.state.downloading_libraries=\u6b63\u5728\u4e0b\u8f7d\u5fc5\u8981\u6587\u4ef6
launch.state.decompressing_natives=\u6b63\u5728\u91ca\u653e\u672c\u5730\u6587\u4ef6
install.no_version=\u672a\u627e\u5230\u8981\u5b89\u88c5\u7684\u5bf9\u5e94MC\u7248\u672c
install.no_version_if_intall=\u672a\u627e\u5230\u8981\u5b89\u88c5\u7684\u5bf9\u5e94MC\u7248\u672c\uff0c\u662f\u5426\u81ea\u52a8\u5b89\u88c5\u9700\u8981\u7684MC\u7248\u672c\uff1f
install.not_refreshed=\u672a\u5237\u65b0\u5217\u8868

View File

@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=Did not finish decompressing native li
launch.wrong_javadir=Wrong Java Dir, will reset to default Java dir.
launch.exited_abnormally=Game exited abnormally, please visit the log, or ask someone for help.
launch.state.logging_in=Logging In
launch.state.generating_launching_codes=Generating Launching Codes
launch.state.downloading_libraries=Downloading dependencies
launch.state.decompressing_natives=Decompressing natives
install.no_version=The version is not found.
install.no_version_if_intall=The needed version is not found, should install the version automatically?
install.not_refreshed=The installer list is not refreshed.

View File

@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=Did not finish decompressing native li
launch.wrong_javadir=Wrong Java Dir, will reset to default Java dir.
launch.exited_abnormally=Game exited abnormally, please visit the log, or ask someone for help.
launch.state.logging_in=Logging In
launch.state.generating_launching_codes=Generating Launching Codes
launch.state.downloading_libraries=Downloading dependencies
launch.state.decompressing_natives=Decompressing natives
install.no_version=The version is not found.
install.no_version_if_intall=The needed version is not found, should install the version automatically?
install.not_refreshed=The installer list is not refreshed.

View File

@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=未能解壓遊戲本地庫,還要
launch.wrong_javadir=錯誤的Java路徑將自動重置為默認Java路徑。
launch.exited_abnormally=遊戲非正常退出,請查看日誌資料,或聯繫他人尋求幫助。
launch.state.logging in=登錄中
launch.state.generating launching codes=正在生成啟動代碼
launch.state.downloading_libraries=正在下載必要文件
launch.state.decompressing_natives=正在釋放本地文件
install.no_version=未找到要安裝的對應MC版本
install.no_version_if_intall=未找到要安裝的對應MC版本是否自动安装需要的MC版本
install.not_refreshed=未刷新列表

View File

@@ -27,6 +27,11 @@ launch.not_finished_decompressing_natives=\u672a\u80fd\u89e3\u58d3\u904a\u6232\u
launch.wrong_javadir=\u932f\u8aa4\u7684Java\u8def\u5f91\uff0c\u5c07\u81ea\u52d5\u91cd\u7f6e\u70ba\u9ed8\u8a8dJava\u8def\u5f91\u3002
launch.exited_abnormally=\u904a\u6232\u975e\u6b63\u5e38\u9000\u51fa\uff0c\u8acb\u67e5\u770b\u65e5\u8a8c\u8cc7\u6599\uff0c\u6216\u806f\u7e6b\u4ed6\u4eba\u5c0b\u6c42\u5e6b\u52a9\u3002
launch.state.logging in=\u767b\u9304\u4e2d
launch.state.generating launching codes=\u6b63\u5728\u751f\u6210\u555f\u52d5\u4ee3\u78bc
launch.state.downloading_libraries=\u6b63\u5728\u4e0b\u8f09\u5fc5\u8981\u6587\u4ef6
launch.state.decompressing_natives=\u6b63\u5728\u91cb\u653e\u672c\u5730\u6587\u4ef6
install.no_version=\u672a\u627e\u5230\u8981\u5b89\u88dd\u7684\u5c0d\u61c9MC\u7248\u672c
install.no_version_if_intall=\u672a\u627e\u5230\u8981\u5b89\u88dd\u7684\u5c0d\u61c9MC\u7248\u672c\uff0c\u662f\u5426\u81ea\u52a8\u5b89\u88c5\u9700\u8981\u7684MC\u7248\u672c\uff1f
install.not_refreshed=\u672a\u5237\u65b0\u5217\u8868