Index: /trunk/src/org/openstreetmap/josm/actions/RestartAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/RestartAction.java	(revision 17389)
+++ /trunk/src/org/openstreetmap/josm/actions/RestartAction.java	(revision 17390)
@@ -14,4 +14,5 @@
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
@@ -35,4 +36,6 @@
 public class RestartAction extends JosmAction {
 
+    private static final String APPLE_OSASCRIPT = "/usr/bin/osascript";
+
     // AppleScript to restart OS X package
     private static final String RESTART_APPLE_SCRIPT =
@@ -44,4 +47,7 @@
             + "tell application \"JOSM\" to activate";
 
+    // Make sure we're able to retrieve restart commands before initiating shutdown (#13784)
+    private static final List<String> cmd = determineRestartCommands();
+
     /**
      * Constructs a new {@code RestartAction}.
@@ -60,9 +66,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        try {
-            restartJOSM();
-        } catch (IOException ex) {
-            Logging.error(ex);
-        }
+        restartJOSM();
     }
 
@@ -73,12 +75,11 @@
      */
     public static boolean isRestartSupported() {
-        return getSystemProperty("sun.java.command") != null;
+        return !cmd.isEmpty();
     }
 
     /**
      * Restarts the current Java application.
-     * @throws IOException in case of any I/O error
-     */
-    public static void restartJOSM() throws IOException {
+     */
+    public static void restartJOSM() {
         // If JOSM has been started with property 'josm.restart=true' this means
         // it is executed by a start script that can handle restart.
@@ -89,17 +90,18 @@
         }
 
-        if (isRestartSupported() && !MainApplication.exitJosm(false, 0, SaveLayersDialog.Reason.RESTART)) return;
-        final List<String> cmd;
-        // special handling for OSX .app package
-        if (PlatformManager.isPlatformOsx() && getSystemProperty("java.library.path").contains("/JOSM.app/Contents/MacOS")) {
-            cmd = getAppleCommands();
-        } else {
-            cmd = getCommands();
+        // Log every related environmentvariable for debug purpose
+        if (isDebugSimulation()) {
+            logEnvironment();
         }
         Logging.info("Restart "+cmd);
-        if (Logging.isDebugEnabled() && Config.getPref().getBoolean("restart.debug.simulation")) {
+        if (isDebugSimulation()) {
             Logging.debug("Restart cancelled to get debug info");
             return;
         }
+
+        // Initiate shutdown
+        if (isRestartSupported() && !MainApplication.exitJosm(false, 0, SaveLayersDialog.Reason.RESTART))
+            return;
+
         // execute the command in a shutdown hook, to be sure that all the
         // resources have been disposed before restarting the application
@@ -118,7 +120,44 @@
     }
 
-    private static List<String> getAppleCommands() {
+    private static boolean isDebugSimulation() {
+        return Logging.isDebugEnabled() && Config.getPref().getBoolean("restart.debug.simulation");
+    }
+
+    private static void logEnvironment() {
+        logEnvironmentVariable("java.home");
+        logEnvironmentVariable("java.class.path");
+        logEnvironmentVariable("java.library.path");
+        logEnvironmentVariable("jnlpx.origFilenameArg");
+        logEnvironmentVariable("sun.java.command");
+    }
+
+    private static void logEnvironmentVariable(String var) {
+        Logging.debug("{0}: {1}", var, getSystemProperty(var));
+    }
+
+    private static boolean isExecutableFile(File f) {
+        return f.isFile() && f.canExecute();
+    }
+
+    private static List<String> determineRestartCommands() {
+        try {
+            // special handling for OSX .app package
+            if (PlatformManager.isPlatformOsx() && getSystemProperty("java.library.path").contains("/JOSM.app/Contents/MacOS")) {
+                return getAppleCommands();
+            } else {
+                return getCommands();
+            }
+        } catch (IOException e) {
+            Logging.error(e);
+            return Collections.emptyList();
+        }
+    }
+
+    private static List<String> getAppleCommands() throws IOException {
+        if (!isExecutableFile(new File(APPLE_OSASCRIPT))) {
+            throw new IOException("Unable to find suitable osascript at " + APPLE_OSASCRIPT);
+        }
         final List<String> cmd = new ArrayList<>();
-        cmd.add("/usr/bin/osascript");
+        cmd.add(APPLE_OSASCRIPT);
         for (String line : RESTART_APPLE_SCRIPT.split("\n", -1)) {
             cmd.add("-e");
@@ -178,5 +217,5 @@
         final String java = getSystemProperty("java.home") + File.separator + "bin" + File.separator +
                 (PlatformManager.isPlatformWindows() ? "java.exe" : "java");
-        if (!new File(java).isFile()) {
+        if (!isExecutableFile(new File(java))) {
             throw new IOException("Unable to find suitable java runtime at "+java);
         }
Index: /trunk/src/org/openstreetmap/josm/gui/MainApplication.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 17389)
+++ /trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 17390)
@@ -1232,9 +1232,5 @@
                     Logging.info(tr("Detected no useable IPv6 network, preferring IPv4 over IPv6 after next restart."));
                     Config.getPref().putBoolean("validated.ipv6", hasv6); // be sure it is stored before the restart!
-                    try {
-                        RestartAction.restartJOSM();
-                    } catch (IOException e) {
-                        Logging.error(e);
-                    }
+                    RestartAction.restartJOSM();
                 }
                 Config.getPref().putBoolean("validated.ipv6", hasv6);
Index: /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 17389)
+++ /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 17390)
@@ -617,9 +617,5 @@
                         Config.getPref().putList("plugins", new ArrayList<>(plugins));
                         // restart
-                        try {
-                            RestartAction.restartJOSM();
-                        } catch (IOException e) {
-                            Logging.error(e);
-                        }
+                        RestartAction.restartJOSM();
                     } else {
                         Logging.warn("No plugin downloaded, restart canceled");
