From 95b971150b84f1744063941edb69247cf791cc9f Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Thu, 21 Apr 2016 23:54:33 +0200 Subject: [PATCH] Fix OS version check --- .../io/bitsquare/common/util/Utilities.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/io/bitsquare/common/util/Utilities.java b/common/src/main/java/io/bitsquare/common/util/Utilities.java index 5a70fd2195..b4df752f39 100644 --- a/common/src/main/java/io/bitsquare/common/util/Utilities.java +++ b/common/src/main/java/io/bitsquare/common/util/Utilities.java @@ -118,13 +118,29 @@ public class Utilities { return System.getProperty("os.name").toLowerCase(); } + //TODO remove logs public static boolean isCorrectOSArchitecture() { - String osArch = System.getProperty("os.arch"); String jvmArch = System.getProperty("sun.arch.data.model"); - //TODO remove log - log.warn("osArch " + osArch); log.warn("jvmArch " + jvmArch); - return osArch.endsWith(jvmArch); + log.warn("System.getenv(\"ProgramFiles(x86)\") " + System.getenv("ProgramFiles(x86)")); + if (isWindows()) { + // See: https://stackoverflow.com/questions/20856694/how-to-find-the-os-bit-type + String arch = System.getenv("PROCESSOR_ARCHITECTURE"); + String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432"); + + String realArch = arch.endsWith("64") + || wow64Arch != null && wow64Arch.endsWith("64") + ? "64" : "32"; + + log.warn("arch " + arch); + log.warn("wow64Arch " + wow64Arch); + log.warn("realArch " + realArch); + return realArch.endsWith(jvmArch); + } else { + String osArch = System.getProperty("os.arch"); + log.warn("osArch " + osArch); + return osArch.endsWith(jvmArch); + } } public static void openURI(URI uri) throws IOException {