From 22c64acea7a73ecddc75b9490b5aa0b57a243f00 Mon Sep 17 00:00:00 2001 From: flaw600 Date: Tue, 2 Feb 2016 12:04:29 -0600 Subject: [PATCH 1/2] Potential fix to the detection of 32 bit Java on 64 bit Windows problem aka #231 --- .../java/com/atlauncher/data/Settings.java | 84 ++++++++++--------- src/main/java/com/atlauncher/utils/Utils.java | 45 ++++++---- 2 files changed, 74 insertions(+), 55 deletions(-) diff --git a/src/main/java/com/atlauncher/data/Settings.java b/src/main/java/com/atlauncher/data/Settings.java index 7a7555179..b5aee292b 100644 --- a/src/main/java/com/atlauncher/data/Settings.java +++ b/src/main/java/com/atlauncher/data/Settings.java @@ -17,37 +17,6 @@ */ package com.atlauncher.data; -import com.atlauncher.App; -import com.atlauncher.Gsons; -import com.atlauncher.LogManager; -import com.atlauncher.Update; -import com.atlauncher.data.json.LauncherLibrary; -import com.atlauncher.exceptions.InvalidMinecraftVersion; -import com.atlauncher.exceptions.InvalidPack; -import com.atlauncher.gui.LauncherConsole; -import com.atlauncher.gui.components.LauncherBottomBar; -import com.atlauncher.gui.dialogs.ProgressDialog; -import com.atlauncher.gui.tabs.InstancesTab; -import com.atlauncher.gui.tabs.NewsTab; -import com.atlauncher.gui.tabs.PacksTab; -import com.atlauncher.thread.LoggingThread; -import com.atlauncher.utils.ATLauncherAPIUtils; -import com.atlauncher.utils.HTMLUtils; -import com.atlauncher.utils.MojangAPIUtils; -import com.atlauncher.utils.Timestamper; -import com.atlauncher.utils.Utils; -import com.google.gson.JsonIOException; -import com.google.gson.JsonSyntaxException; -import com.google.gson.reflect.TypeToken; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; - -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; import java.awt.Dialog.ModalityType; import java.awt.FlowLayout; import java.awt.Window; @@ -90,6 +59,39 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +import com.atlauncher.App; +import com.atlauncher.Gsons; +import com.atlauncher.LogManager; +import com.atlauncher.Update; +import com.atlauncher.data.json.LauncherLibrary; +import com.atlauncher.exceptions.InvalidMinecraftVersion; +import com.atlauncher.exceptions.InvalidPack; +import com.atlauncher.gui.LauncherConsole; +import com.atlauncher.gui.components.LauncherBottomBar; +import com.atlauncher.gui.dialogs.ProgressDialog; +import com.atlauncher.gui.tabs.InstancesTab; +import com.atlauncher.gui.tabs.NewsTab; +import com.atlauncher.gui.tabs.PacksTab; +import com.atlauncher.thread.LoggingThread; +import com.atlauncher.utils.ATLauncherAPIUtils; +import com.atlauncher.utils.HTMLUtils; +import com.atlauncher.utils.MojangAPIUtils; +import com.atlauncher.utils.Timestamper; +import com.atlauncher.utils.Utils; +import com.google.gson.JsonIOException; +import com.google.gson.JsonSyntaxException; +import com.google.gson.reflect.TypeToken; + /** * Settings class for storing all data for the Launcher and the settings of the user. * @@ -289,7 +291,7 @@ public void loadEverything() { loadServerProperty(true); // Get users Server preference - if (Utils.isWindows() && this.javaPath.contains("x86")) { + if (Utils.isWindows() && !Utils.is64Bit() && Utils.isWindows64Bit()) { LogManager.warn("You're using 32 bit Java on a 64 bit Windows install!"); String[] options = {Language.INSTANCE.localize("common.yes"), Language.INSTANCE.localize("common.no")}; int ret = JOptionPane.showOptionDialog(App.settings.getParent(), HTMLUtils.centerParagraph(Language @@ -498,7 +500,8 @@ public void checkResources() { final ProgressDialog dialog = new ProgressDialog(Language.INSTANCE.localize("settings" + "" + ".rearrangingresources"), 0, Language.INSTANCE.localize("settings.rearrangingresources"), null); Thread thread = new Thread() { - public void run() { + @Override + public void run() { File indexesDir = new File(getResourcesDir(), "indexes"); File objectsDir = new File(getResourcesDir(), "objects"); File virtualDir = new File(getResourcesDir(), "virtual"); @@ -2027,7 +2030,8 @@ public List getPacks() { public List getPacksSortedAlphabetically() { List packs = new LinkedList(this.packs); Collections.sort(packs, new Comparator() { - public int compare(Pack result1, Pack result2) { + @Override + public int compare(Pack result1, Pack result2) { return result1.getName().compareTo(result2.getName()); } }); @@ -2042,7 +2046,8 @@ public int compare(Pack result1, Pack result2) { public List getPacksSortedPositionally() { List packs = new LinkedList(this.packs); Collections.sort(packs, new Comparator() { - public int compare(Pack result1, Pack result2) { + @Override + public int compare(Pack result1, Pack result2) { return (result1.getPosition() < result2.getPosition()) ? -1 : ((result1.getPosition() == result2 .getPosition()) ? 0 : 1); } @@ -2107,7 +2112,8 @@ public List getInstances() { public ArrayList getInstancesSorted() { ArrayList instances = new ArrayList(this.instances); Collections.sort(instances, new Comparator() { - public int compare(Instance result1, Instance result2) { + @Override + public int compare(Instance result1, Instance result2) { return result1.getName().compareTo(result2.getName()); } }); @@ -3119,14 +3125,16 @@ public String getUserAgent() { /** * @deprecated */ - public String getLocalizedString(String string) { + @Deprecated + public String getLocalizedString(String string) { return Language.INSTANCE.localize(string); } /** * @deprecated */ - public String getLocalizedString(String string, String replace) { + @Deprecated + public String getLocalizedString(String string, String replace) { return Language.INSTANCE.localize(string).replace("%s", replace); } diff --git a/src/main/java/com/atlauncher/utils/Utils.java b/src/main/java/com/atlauncher/utils/Utils.java index 29bac20ef..d6b47c3cd 100644 --- a/src/main/java/com/atlauncher/utils/Utils.java +++ b/src/main/java/com/atlauncher/utils/Utils.java @@ -17,23 +17,6 @@ */ package com.atlauncher.utils; -import com.atlauncher.App; -import com.atlauncher.Gsons; -import com.atlauncher.LogManager; -import com.atlauncher.data.Constants; -import com.atlauncher.data.mojang.ExtractRule; -import com.atlauncher.data.mojang.OperatingSystem; -import com.atlauncher.data.openmods.OpenEyeReportResponse; -import com.atlauncher.evnt.LogEvent.LogType; -import org.tukaani.xz.XZInputStream; - -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.spec.SecretKeySpec; -import javax.imageio.ImageIO; -import javax.net.ssl.HttpsURLConnection; -import javax.swing.ImageIcon; import java.awt.Desktop; import java.awt.Dimension; import java.awt.Font; @@ -97,6 +80,25 @@ import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.spec.SecretKeySpec; +import javax.imageio.ImageIO; +import javax.net.ssl.HttpsURLConnection; +import javax.swing.ImageIcon; + +import org.tukaani.xz.XZInputStream; + +import com.atlauncher.App; +import com.atlauncher.Gsons; +import com.atlauncher.LogManager; +import com.atlauncher.data.Constants; +import com.atlauncher.data.mojang.ExtractRule; +import com.atlauncher.data.mojang.OperatingSystem; +import com.atlauncher.data.openmods.OpenEyeReportResponse; +import com.atlauncher.evnt.LogEvent.LogType; + public class Utils { public static String error(Throwable t) { StringBuilder builder = new StringBuilder(); @@ -396,6 +398,15 @@ public static boolean isLinux() { public static boolean is64Bit() { return System.getProperty("sun.arch.data.model").contains("64"); } + + /** + * Checks if Windows is 64 bit + * + * @return true, if it is 64 bit + */ + public static boolean isWindows64Bit(){ + return System.getenv("ProgramFiles(x86)") != null; + } /** * Gets the arch. From 92f8ab72158eb7de1eefdc13801b791e5d01793c Mon Sep 17 00:00:00 2001 From: flaw600 Date: Wed, 3 Feb 2016 01:57:20 -0600 Subject: [PATCH 2/2] Fix for #231 accepted on the master branch and changelog updated to reflect the fix. Please don't close until the 3.3.0.0 branch is merged as well --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07a6c12e5..b241f4bda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,4 +3,5 @@ Changelog ### 3.2.3.2 -- Fix issue with linked/depends mods not cascading their changes to the mods they enable \ No newline at end of file +- Fix issue with linked/depends mods not cascading their changes to the mods they enable +- Fixed issue that gave a bad '32 bit Java on 64 bit Windows' warning when 64 bit Java was installed in the x86 directory \ No newline at end of file