Index: trunk/src/org/openstreetmap/josm/actions/RestartAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/RestartAction.java	(revision 7752)
+++ trunk/src/org/openstreetmap/josm/actions/RestartAction.java	(revision 7755)
@@ -90,11 +90,6 @@
                 }
             } else {
-                // java binary
-                final String java = System.getProperty("java.home") + File.separator + "bin" + File.separator +
-                        (Main.isPlatformWindows() ? "java.exe" : "java");
-                if (!new File(java).isFile()) {
-                    throw new IOException("Unable to find suitable java runtime at "+java);
-                }
-                cmd.add(java);
+                // java binary is resolved later
+                cmd.add(null);
                 // vm arguments
                 for (String arg : ManagementFactory.getRuntimeMXBean().getInputArguments()) {
@@ -105,29 +100,44 @@
                     }
                 }
-                // program main and program arguments (be careful a sun property. might not be supported by all JVM)
-                String[] mainCommand = System.getProperty("sun.java.command").split(" ");
-                // look for a .jar in all chunks to support paths with spaces (fix #9077)
-                String jarPath = mainCommand[0];
-                for (int i = 1; i < mainCommand.length && !jarPath.endsWith(".jar"); i++) {
-                    jarPath += " " + mainCommand[i];
-                }
-                // program main is a jar
-                if (jarPath.endsWith(".jar")) {
-                    // if it's a jar, add -jar mainJar
-                    cmd.add("-jar");
-                    cmd.add(new File(jarPath).getPath());
+                final String javadir = System.getProperty("java.home") + File.separator + "bin" + File.separator;
+                final String java;
+                // Detect JNLP files launched with jp2launcher
+                boolean jp2launcher = cmd.contains("-secure") && cmd.contains("-javaws");
+                if (jp2launcher) {
+                    java = javadir + (Main.isPlatformWindows() ? "jp2launcher.exe" : "jp2launcher");
                 } else {
-                    // else it's a .class, add the classpath and mainClass
-                    cmd.add("-cp");
-                    cmd.add("\"" + System.getProperty("java.class.path") + "\"");
-                    cmd.add(mainCommand[0]);
-                }
-                // if it's webstart add JNLP file
-                String jnlp = System.getProperty("jnlp.application.href");
-                if (jnlp != null) {
-                    cmd.add(jnlp);
-                }
-                // finally add program arguments
-                cmd.addAll(Arrays.asList(Main.commandLineArgs));
+                    java = javadir + (Main.isPlatformWindows() ? "java.exe" : "java");
+                }
+                if (!new File(java).isFile()) {
+                    throw new IOException("Unable to find suitable java runtime at "+java);
+                }
+                cmd.set(0, java);
+                if (!jp2launcher) {
+                    // program main and program arguments (be careful a sun property. might not be supported by all JVM)
+                    String[] mainCommand = System.getProperty("sun.java.command").split(" ");
+                    // look for a .jar in all chunks to support paths with spaces (fix #9077)
+                    String jarPath = mainCommand[0];
+                    for (int i = 1; i < mainCommand.length && !jarPath.endsWith(".jar"); i++) {
+                        jarPath += " " + mainCommand[i];
+                    }
+                    // program main is a jar
+                    if (jarPath.endsWith(".jar")) {
+                        // if it's a jar, add -jar mainJar
+                        cmd.add("-jar");
+                        cmd.add(new File(jarPath).getPath());
+                    } else {
+                        // else it's a .class, add the classpath and mainClass
+                        cmd.add("-cp");
+                        cmd.add("\"" + System.getProperty("java.class.path") + "\"");
+                        cmd.add(mainCommand[0]);
+                    }
+                    // if it's webstart add JNLP file
+                    String jnlp = System.getProperty("jnlp.application.href");
+                    if (jnlp != null) {
+                        cmd.add(jnlp);
+                    }
+                    // finally add program arguments
+                    cmd.addAll(Arrays.asList(Main.commandLineArgs));
+                }
             }
             Main.info("Restart "+cmd);
