private final static String headlessProperty = "java.awt.headless";
- private static boolean checkJVMSymlink(String testBin)
- {
- File testBinFile = new File(testBin);
- if (!testBinFile.exists())
- {
- return false;
- }
- File targetFile = null;
- try
- {
- targetFile = testBinFile.getCanonicalFile();
- } catch (IOException e)
- {
- return false;
- }
- if (targetFile != null && ("java".equals(targetFile.getName())
- || "java.exe".equals(targetFile.getName())))
- {
- return true;
- }
- return false;
- }
-
/**
* main method for jalview.bin.Launcher. This restarts the same JRE's JVM with
* the same arguments but with memory adjusted based on extracted -jvmmempc
+ ") may lead to problems. This installation of Jalview should be used with Java "
+ LaunchUtils.getJavaCompileVersion() + ".");
}
- final String appName = ChannelProperties.getProperty("app_name");
- final String javaBinDir = System.getProperty("java.home")
- + File.separator + "bin" + File.separator;
- String javaBin = null;
- for (String name : new String[] { appName, "Jalview", "java",
- "java.exe" })
- {
- if (checkJVMSymlink(javaBinDir + name))
- {
- javaBin = javaBinDir + name;
- break;
- }
- }
- if (javaBin == null)
- {
- javaBin = "java";
- }
-
- List<String> command = new ArrayList<>();
- command.add(javaBin);
-
- String memSetting = null;
-
- boolean isAMac = System.getProperty("os.name").indexOf("Mac") > -1;
-
- for (String jvmArg : ManagementFactory.getRuntimeMXBean()
- .getInputArguments())
- {
- command.add(jvmArg);
- }
- command.add("-cp");
- command.add(ManagementFactory.getRuntimeMXBean().getClassPath());
String jvmmempc = null;
String jvmmemmax = null;
headless = false;
}
+ final String appName = ChannelProperties.getProperty("app_name");
+
+ // if we're using jalview.bin.Launcher we always assume a console is in use
+ final String javaBin = LaunchUtils.findJavaBin(true);
+
+ List<String> command = new ArrayList<>();
+ command.add(javaBin);
+
+ String memSetting = null;
+
+ for (String jvmArg : ManagementFactory.getRuntimeMXBean()
+ .getInputArguments())
+ {
+ command.add(jvmArg);
+ }
+ command.add("-cp");
+ command.add(ManagementFactory.getRuntimeMXBean().getClassPath());
+
// use saved preferences if no cmdline args
boolean useCustomisedSettings = LaunchUtils
.getBooleanUserPreference(MemorySetting.CUSTOMISED_SETTINGS);
}
}
- if (isAMac)
+ if (LaunchUtils.isMac)
{
if (!dockIcon)
{