import jalview.util.Platform;
import jalview.ws.jws2.Jws2Discoverer;
+import java.awt.Image;
+import java.awt.Taskbar;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
{
desktop = new Desktop();
desktop.setInBatchMode(true); // indicate we are starting up
+
+ if (Taskbar.isTaskbarSupported())
+ {
+ Taskbar tb = Taskbar.getTaskbar();
+ if (tb.isSupported(Taskbar.Feature.ICON_IMAGE))
+ {
+ try
+ {
+ java.net.URL url = getClass()
+ .getResource("/images/JalviewLogo_Huge.png");
+ if (url != null)
+ {
+ Image image = java.awt.Toolkit.getDefaultToolkit()
+ .createImage(url);
+ tb.setIconImage(image);
+ }
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
desktop.setVisible(true);
desktop.startServiceDiscovery();
if (!aparser.contains("nousagestats"))
--- /dev/null
+package jalview.bin;
+
+import java.io.File;
+import java.lang.management.ManagementFactory;
+import java.lang.management.OperatingSystemMXBean;
+import java.util.ArrayList;
+
+public class Launcher
+{
+
+ private final static String startClass = "jalview.bin.Jalview";
+
+ private final static int maxHeapSizePerCent = 95;
+
+ private final static String dockIconPath = "JalviewLogo_Huge.png";
+
+ public static void main(String[] args)
+ {
+ final String javaBin = System.getProperty("java.home") + File.separator
+ + "bin" + File.separator + "java";
+
+ ArrayList<String> command = new ArrayList<>();
+ command.add(javaBin);
+
+ 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());
+ ArrayList<String> arguments = new ArrayList<>();
+ for (String arg : args)
+ {
+ arguments.add(arg);
+ }
+
+ // add memory setting if not specified
+ boolean memSet = false;
+ boolean dockIcon = false;
+ ARG: for (int i = 0; i < command.size(); i++)
+ {
+ String arg = command.get(i);
+ if (arg.startsWith("-Xmx"))
+ {
+ memSet = true;
+ }
+ else if (arg.startsWith("-Xdock:icon"))
+ {
+ dockIcon = true;
+ }
+ }
+
+ if (!memSet)
+ {
+ long maxMemLong = -1;
+ long physicalMem = getPhysicalMemory();
+ if (physicalMem > 0)
+ {
+ maxMemLong = physicalMem * maxHeapSizePerCent / 100;
+ }
+ if (maxMemLong > 0)
+ {
+ command.add("-Xmx" + Long.toString(maxMemLong));
+ }
+ }
+
+ if (!dockIcon)
+ {
+ command.add("-Xdock:icon=" + dockIconPath);
+ // -Xdock:name=... doesn't actually work :(
+ // Leaving it in in case it gets fixed
+ command.add("-Xdock:name=" + "Jalview");
+ }
+
+ command.add(startClass);
+ command.addAll(arguments);
+
+ final ProcessBuilder builder = new ProcessBuilder(command);
+
+ System.out.println("COMMAND: " + String.join(" ", builder.command()));
+
+ try
+ {
+ builder.inheritIO();
+ builder.start();
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ // System.exit(0);
+
+ }
+
+ public static long getPhysicalMemory()
+ {
+ final OperatingSystemMXBean o = ManagementFactory
+ .getOperatingSystemMXBean();
+
+ try
+ {
+ if (o instanceof com.sun.management.OperatingSystemMXBean)
+ {
+ final com.sun.management.OperatingSystemMXBean osb = (com.sun.management.OperatingSystemMXBean) o;
+ return osb.getTotalPhysicalMemorySize();
+ }
+ } catch (NoClassDefFoundError e)
+ {
+ // com.sun.management.OperatingSystemMXBean doesn't exist in this JVM
+ System.out.println("No com.sun.management.OperatingSystemMXBean");
+ }
+
+ // We didn't get a com.sun.management.OperatingSystemMXBean.
+ return -1;
+ }
+
+}