X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=getdown%2Fsrc%2Fgetdown%2Fcore%2Fsrc%2Fmain%2Fjava%2Fcom%2Fthreerings%2Fgetdown%2Futil%2FLaunchUtil.java;h=1faaa28a4ee0e59b3e69acaa0bfd536992893e8f;hb=0d9ac702f322ab3c1cc5ead5a01b69215cce8424;hp=0781a11882842ee85d2a983d2c6217ad67c0fd58;hpb=ed379d3f998a6aea83ce8c9cdaab2ec8234adb6a;p=jalview.git diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java index 0781a11..1faaa28 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java @@ -17,6 +17,8 @@ import javax.xml.bind.DatatypeConverter; import java.security.MessageDigest; +import jalview.util.LaunchUtils; + import static com.threerings.getdown.Log.log; /** @@ -88,6 +90,7 @@ public class LaunchUtil return getJVMPath(appdir, false); } + private static String jvmPath = null; /** * Reconstructs the path to the JVM used to launch this process. * @@ -95,22 +98,27 @@ public class LaunchUtil */ public static String getJVMPath (File appdir, boolean windebug) { - // first look in our application directory for an installed VM - String vmpath = checkJVMPath(new File(appdir, LOCAL_JAVA_DIR).getAbsolutePath(), windebug); - if (vmpath == null && isMacOS()) { - vmpath = checkJVMPath(new File(appdir, LOCAL_JAVA_DIR + "/Contents/Home").getAbsolutePath(), windebug); + if (jvmPath != null) { + return jvmPath; } + + // first look in our application directory for an installed VM + final String appDir = isMacOS() ? + (new File(appdir, LOCAL_JAVA_DIR).getAbsolutePath()) + "/Contents/Home" + : new File(appdir, LOCAL_JAVA_DIR).getAbsolutePath(); + + String javaBin = LaunchUtils.findJavaBin(appDir, windebug, false); // then fall back to the VM in which we're already running - if (vmpath == null) { - vmpath = checkJVMPath(System.getProperty("java.home"), windebug); + if (javaBin == null) { + javaBin = LaunchUtils.findJavaBin(System.getProperty("java.home"), windebug, false); } // then throw up our hands and hope for the best - if (vmpath == null) { + if (javaBin == null) { + javaBin = LaunchUtils.findJavaBin(null, windebug, true); log.warning("Unable to find java [appdir=" + appdir + ", java.home=" + System.getProperty("java.home") + "]!"); - vmpath = "java"; } // Oddly, the Mac OS X specific java flag -Xdock:name will only work if java is launched @@ -120,15 +128,16 @@ public class LaunchUtil if (isMacOS()) { try { File localVM = new File("/usr/bin/java").getCanonicalFile(); - if (localVM.equals(new File(vmpath).getCanonicalFile())) { - vmpath = "/usr/bin/java"; + if (localVM.equals(new File(javaBin).getCanonicalFile())) { + javaBin = "/usr/bin/java"; } } catch (IOException ioe) { log.warning("Failed to check Mac OS canonical VM path.", ioe); } } - return vmpath; + jvmPath = javaBin; + return jvmPath; } private static String _getMD5FileChecksum (File file) {