I am trying to restart the Java program in debug mode using this code
public static final string SUN_JAVA_COMMAND = "sun.java.command"; Public static zero restart application () throws IOException {try {string java = System.getProperty ("java.home") + "/ bin / java"; Last stringbuffer CMD = new stringbuffer ("\" "+ +" + "\" "); String [] main command = system.jetproperty (SUN_JAVA_COMMAND) .split (""); If (mainCommand [0] .endsWith (".jar")) {cmd.append ("- jar" + new file (main command [0]). GetPath ()); } And {cmd.append ("- cp \" "+ System.getProperty (" java.class.path ") +" \ "" + + main command [0]); } Cmd.append (""); (Int i = 1; i & lt; mainCommand.length; i ++) for {cmd.append (""); Cmd.append (mainCommand [i]); } Cmd.append ("-agentlib: jdwp = transport = dt_socket, server = y, suspended = n, address = 8000"); . Runtime.getRuntime () Executive (cmd.toString ()); System.exit (0); } Hold (exception e) {new IOException ("while trying to restart the error", e); }} Every time this application starts from the main method
public static zero principal (string [] args throws an exception {boolean isDebug = Java .lang.management.ManagementFactory.getRuntimeMXBean (). GetInputArguments () ToString () IndexOf ("- agentlib: jdwp") & gt; 0; Employmentpan Shmosse Delog (empty, isDebug); Utility.restartApplication (); } Joppepten always falsifies the message why this work is not done
with problem or resume application in iDebug; I think the problem is restarted.
Your isDebug right hand side seems difficult enough that it Not sure if it should work or not. You do not set it to just true and check whether the debugger starts, later you know whether it is isDebug evaluation or debugger is restarted or not.
No comments:
Post a Comment