Note that there are some explanatory texts on larger screens.

plurals
  1. PORestarting program in debug mode
    text
    copied!<p>I am trying to restart a java program in debug mode using this code</p> <pre><code>public static final String SUN_JAVA_COMMAND = "sun.java.command"; public static void restartApplication() throws IOException { try { String java = System.getProperty("java.home") + "/bin/java"; final StringBuffer cmd = new StringBuffer("\"" + java + "\" "); String[] mainCommand = System.getProperty(SUN_JAVA_COMMAND).split(" "); if (mainCommand[0].endsWith(".jar")) { cmd.append("-jar " + new File(mainCommand[0]).getPath()); } else { cmd.append("-cp \"" + System.getProperty("java.class.path") + "\" " + mainCommand[0]); } cmd.append(""); for (int i = 1; i &lt; mainCommand.length; i++) { cmd.append(" "); cmd.append(mainCommand[i]); } cmd.append(" -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"); Runtime.getRuntime().exec(cmd.toString()); System.exit(0); } catch (Exception e) { throw new IOException("Error while trying to restart the application", e); } } </code></pre> <p>However each time the application starts from this main method </p> <pre><code>public static void main(String[] args) throws Exception { boolean isDebug = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") &gt; 0; JOptionPane.showMessageDialog(null, isDebug); Utility.restartApplication(); } </code></pre> <p>The joptionpane always displays the message false why wont this work</p> <p>Is the problem in the isDebug or with the restart application; I think the problem is the restart.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload