From: Ben Soares Date: Thu, 25 May 2023 12:55:37 +0000 (+0100) Subject: JAL-3820 Create and use 'Jalview app' symblinks to java executable. Fixes grouped... X-Git-Tag: Release_2_11_4_0~297 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4ce97aceb541e3afaed87cdc444d2f52d1ebc944;p=jalview.git JAL-3820 Create and use 'Jalview app' symblinks to java executable. Fixes grouped naming in linux taskbar, possibly macOS dock, still to check. --- diff --git a/getdown/lib/FJVL_VERSION b/getdown/lib/FJVL_VERSION index 1a5992a..35bd812 100644 --- a/getdown/lib/FJVL_VERSION +++ b/getdown/lib/FJVL_VERSION @@ -1 +1 @@ -1.8.3-1.2.13_FJVL +1.8.3-1.2.14_FJVL diff --git a/getdown/lib/JVL_VERSION b/getdown/lib/JVL_VERSION index 60daf6c..0a14c3b 100644 --- a/getdown/lib/JVL_VERSION +++ b/getdown/lib/JVL_VERSION @@ -1 +1 @@ -1.8.3-1.2.13_JVL +1.8.3-1.2.14_JVL diff --git a/getdown/lib/getdown-core.jar b/getdown/lib/getdown-core.jar index 5c98d23..41540fd 100644 Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ diff --git a/getdown/lib/getdown-launcher-local.jar b/getdown/lib/getdown-launcher-local.jar index b022d9f..c1237da 100644 Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ diff --git a/getdown/lib/getdown-launcher.jar b/getdown/lib/getdown-launcher.jar index b9e3c6b..46e7327 100644 Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ diff --git a/getdown/src/getdown/ant/pom.xml b/getdown/src/getdown/ant/pom.xml index ed0f34a..b0c54e2 100644 --- a/getdown/src/getdown/ant/pom.xml +++ b/getdown/src/getdown/ant/pom.xml @@ -4,7 +4,7 @@ com.threerings.getdown getdown - 1.8.3-1.2.13_FJVL + 1.8.3-1.2.14_FJVL getdown-ant diff --git a/getdown/src/getdown/core/pom.xml b/getdown/src/getdown/core/pom.xml index a7dfa07..5dd429d 100644 --- a/getdown/src/getdown/core/pom.xml +++ b/getdown/src/getdown/core/pom.xml @@ -4,7 +4,7 @@ com.threerings.getdown getdown - 1.8.3-1.2.13_FJVL + 1.8.3-1.2.14_FJVL getdown-core 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 31a69c3..0781a11 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 @@ -233,12 +233,47 @@ public class LaunchUtil public static final boolean isLinux () { return _isLinux; } /** + * Check if a symlink (or file) points to a JVM + */ + 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; + } + + /** * Checks whether a Java Virtual Machine can be located in the supplied path. */ protected static String checkJVMPath (String vmhome, boolean windebug) { String vmbase = vmhome + File.separator + "bin" + File.separator; - String vmpath = vmbase + "java"; + String appName = System.getProperty("channel.app_name", "Jalview"); + String vmpath = vmbase + appName; + if (checkJVMSymlink(vmpath)) { + return vmpath; + } + vmpath = vmbase + "Jalview"; + if (checkJVMSymlink(vmpath)) { + return vmpath; + } + vmpath = vmbase + "java"; if (new File(vmpath).exists()) { return vmpath; } diff --git a/getdown/src/getdown/launcher/pom.xml b/getdown/src/getdown/launcher/pom.xml index 6cf40a8..ea3b6ef 100644 --- a/getdown/src/getdown/launcher/pom.xml +++ b/getdown/src/getdown/launcher/pom.xml @@ -4,7 +4,7 @@ com.threerings.getdown getdown - 1.8.3-1.2.13_FJVL + 1.8.3-1.2.14_FJVL getdown-launcher diff --git a/getdown/src/getdown/mvn_cmd b/getdown/src/getdown/mvn_cmd index 36bc298..b30194f 100755 --- a/getdown/src/getdown/mvn_cmd +++ b/getdown/src/getdown/mvn_cmd @@ -3,7 +3,7 @@ if [ x$JVLVERSION != x ]; then export VERSION=$JVLVERSION else - export VERSION=1.8.3-1.2.13_JVL + export VERSION=1.8.3-1.2.14_JVL fi if [ x${VERSION%_JVL} = x$VERSION ]; then diff --git a/getdown/src/getdown/pom.xml b/getdown/src/getdown/pom.xml index dc12610..ef8c811 100644 --- a/getdown/src/getdown/pom.xml +++ b/getdown/src/getdown/pom.xml @@ -10,7 +10,7 @@ com.threerings.getdown getdown pom - 1.8.3-1.2.13_FJVL + 1.8.3-1.2.14_FJVL getdown An application installer and updater. diff --git a/j11lib/getdown-core.jar b/j11lib/getdown-core.jar index 5c98d23..41540fd 100644 Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ diff --git a/j8lib/getdown-core.jar b/j8lib/getdown-core.jar index 5c98d23..41540fd 100644 Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ diff --git a/src/jalview/bin/Launcher.java b/src/jalview/bin/Launcher.java index f29e0a1..246f0a2 100644 --- a/src/jalview/bin/Launcher.java +++ b/src/jalview/bin/Launcher.java @@ -53,6 +53,29 @@ public class Launcher private final static String dockIconPath = ChannelProperties .getProperty("logo.512"); + 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 @@ -70,9 +93,22 @@ public class Launcher + ") may lead to problems. This installation of Jalview should be used with Java " + LaunchUtils.getJavaCompileVersion() + "."); } - - final String javaBin = System.getProperty("java.home") + File.separator - + "bin" + File.separator + "java"; + final String appName = ChannelProperties.getProperty("app_name"); + final String javaBinDir = System.getProperty("java.home") + + File.separator + "bin" + File.separator; + String javaBin = null; + if (javaBin == null && checkJVMSymlink(javaBinDir + appName)) + { + javaBin = javaBinDir + appName; + } + if (javaBin == null && checkJVMSymlink(javaBinDir + "Jalview")) + { + javaBin = javaBinDir + "Jalview"; + } + if (javaBin == null) + { + javaBin = "java"; + } List command = new ArrayList<>(); command.add(javaBin); @@ -232,14 +268,13 @@ public class Launcher { // -Xdock:name=... doesn't actually work :( // Leaving it in in case it gets fixed - command.add( - "-Xdock:name=" + ChannelProperties.getProperty("app_name")); + command.add("-Xdock:name=" + appName); // this launches WITHOUT an icon in the macOS dock. Could be useful for // getdown? // command.add("-Dapple.awt.UIElement=false"); // This also does not work for the dock command.add("-Dcom.apple.mrj.application.apple.menu.about.name=" - + ChannelProperties.getProperty("app_name")); + + appName); } } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index fb3bbc0..1c55476 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -442,6 +442,7 @@ public class Desktop extends jalview.jbgui.GDesktop System.err.println( "Linux platform only! You may have the following warning next: \"WARNING: An illegal reflective access operation has occurred\"\nThis is expected and cannot be avoided, sorry about that."); } + final String awtAppClassName = "awtAppClassName"; try { Toolkit xToolkit = Toolkit.getDefaultToolkit(); @@ -449,10 +450,10 @@ public class Desktop extends jalview.jbgui.GDesktop Field awtAppClassNameField = null; if (Arrays.stream(declaredFields) - .anyMatch(f -> f.getName().equals("awtAppClassName"))) + .anyMatch(f -> f.getName().equals(awtAppClassName))) { awtAppClassNameField = xToolkit.getClass() - .getDeclaredField("awtAppClassName"); + .getDeclaredField(awtAppClassName); } String title = ChannelProperties.getProperty("app_name"); @@ -463,11 +464,12 @@ public class Desktop extends jalview.jbgui.GDesktop } else { - jalview.bin.Console.debug("XToolkit: awtAppClassName not found"); + jalview.bin.Console + .debug("XToolkit: " + awtAppClassName + " not found"); } } catch (Exception e) { - jalview.bin.Console.debug("Error setting awtAppClassName"); + jalview.bin.Console.debug("Error setting " + awtAppClassName); jalview.bin.Console.trace(Cache.getStackTraceString(e)); } } diff --git a/utils/install4j/install4j10_template.install4j b/utils/install4j/install4j10_template.install4j index 46feaed..f1eee56 100644 --- a/utils/install4j/install4j10_template.install4j +++ b/utils/install4j/install4j10_template.install4j @@ -1,6 +1,6 @@ - - + + @@ -133,7 +133,7 @@ - + @@ -472,7 +472,7 @@ return console.askOkCancel(message, true); - + @@ -593,6 +593,38 @@ return console.askOkCancel(message, true); + + + + + ${compiler:JRE_DIR}/bin/java + + + + + ${compiler:JRE_DIR}/bin/${compiler:JALVIEW_APPLICATION_NAME} + + + + + Util.isLinux() + + + + + + ${compiler:JRE_DIR}/bin/java + + + + + ${compiler:JRE_DIR}/bin/${compiler:JALVIEW_NAME} + + + + + Util.isLinux() + @@ -650,7 +682,7 @@ return console.askOkCancel(message, true); context.getBooleanVariable("addToDockAction") - + @@ -673,7 +705,7 @@ return console.askOkCancel(message, true); context.getBooleanVariable("appendToPathAction") - + @@ -688,7 +720,7 @@ return console.askOkCancel(message, true); context.getBooleanVariable("makeSymbolicLinkAction") && ( Util.isLinux() || Util.isUnixInstaller() ) && ( context.getVariable("unixUserBinDir") != null ) - + @@ -844,13 +876,13 @@ return console.askYesNo(message, true); - + - +