- Timestamp:
- 2014-12-01T03:34:02+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/RestartAction.java
r7756 r7757 90 90 } 91 91 } else { 92 // java binary is resolved later 93 cmd.add(null); 92 // java binary 93 final String java = System.getProperty("java.home") + File.separator + "bin" + File.separator + 94 (Main.isPlatformWindows() ? "java.exe" : "java"); 95 if (!new File(java).isFile()) { 96 throw new IOException("Unable to find suitable java runtime at "+java); 97 } 98 cmd.add(java); 94 99 // vm arguments 95 100 List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); … … 104 109 } 105 110 } 106 final String javadir = System.getProperty("java.home") + File.separator + "bin" + File.separator; 107 final String java; 108 // Detect JNLP files launched with jp2launcher 109 boolean jp2launcher = cmd.contains("-secure") && cmd.contains("-javaws"); 110 if (jp2launcher) { 111 java = javadir + (Main.isPlatformWindows() ? "jp2launcher.exe" : "jp2launcher"); 111 // program main and program arguments (be careful a sun property. might not be supported by all JVM) 112 String[] mainCommand = System.getProperty("sun.java.command").split(" "); 113 // look for a .jar in all chunks to support paths with spaces (fix #9077) 114 String jarPath = mainCommand[0]; 115 for (int i = 1; i < mainCommand.length && !jarPath.endsWith(".jar"); i++) { 116 jarPath += " " + mainCommand[i]; 117 } 118 // program main is a jar 119 if (jarPath.endsWith(".jar")) { 120 // if it's a jar, add -jar mainJar 121 cmd.add("-jar"); 122 cmd.add(new File(jarPath).getPath()); 112 123 } else { 113 java = javadir + (Main.isPlatformWindows() ? "java.exe" : "java"); 114 } 115 if (!new File(java).isFile()) { 116 throw new IOException("Unable to find suitable java runtime at "+java); 117 } 118 cmd.set(0, java); 119 if (!jp2launcher) { 120 // program main and program arguments (be careful a sun property. might not be supported by all JVM) 121 String[] mainCommand = System.getProperty("sun.java.command").split(" "); 122 // look for a .jar in all chunks to support paths with spaces (fix #9077) 123 String jarPath = mainCommand[0]; 124 for (int i = 1; i < mainCommand.length && !jarPath.endsWith(".jar"); i++) { 125 jarPath += " " + mainCommand[i]; 126 } 127 // program main is a jar 128 if (jarPath.endsWith(".jar")) { 129 // if it's a jar, add -jar mainJar 130 cmd.add("-jar"); 131 cmd.add(new File(jarPath).getPath()); 132 } else { 133 // else it's a .class, add the classpath and mainClass 134 cmd.add("-cp"); 135 cmd.add("\"" + System.getProperty("java.class.path") + "\""); 136 cmd.add(mainCommand[0]); 137 } 138 // if it's webstart add JNLP file 139 String jnlp = System.getProperty("jnlp.application.href"); 140 if (jnlp != null) { 141 cmd.add(jnlp); 142 } 143 // finally add program arguments 144 cmd.addAll(Arrays.asList(Main.commandLineArgs)); 145 } 124 // else it's a .class, add the classpath and mainClass 125 cmd.add("-cp"); 126 cmd.add("\"" + System.getProperty("java.class.path") + "\""); 127 cmd.add(mainCommand[0]); 128 } 129 // if it's webstart add JNLP file. Use jnlpx.origFilenameArg instead of jnlp.application.href, 130 // because only this one is present when run from j2plauncher.exe (see #10795) 131 String jnlp = System.getProperty("jnlpx.origFilenameArg"); 132 if (jnlp != null) { 133 cmd.add(jnlp); 134 } 135 // finally add program arguments 136 cmd.addAll(Arrays.asList(Main.commandLineArgs)); 146 137 } 147 138 Main.info("Restart "+cmd);
Note:
See TracChangeset
for help on using the changeset viewer.