On Thu, Dec 10, 2009 at 14:21, Dieter Muecke <[email protected]> wrote: > Instead of restarting JOSM by hand after plugin update the code snippet below > does it programmatically. > It works on Mac OSX but before I submit a patch I would like know how do the > same > on Windows and Linux. > > Kind Regards, > Dieter > > try { > File file = File.createTempFile("josm-restart-", ".sh"); > PrintWriter pw = new PrintWriter(new FileWriter(file)); > pw.println("sleep 1"); > pw.println("open -a JOSM.app"); > pw.close(); > Runtime.getRuntime().exec("/bin/sh " + file.getAbsolutePath()); > System.exit(0); > > } catch (IOException e) { > e.printStackTrace(); > }
Why are you writing a josm-restart.sh instead of just calling /bin/sh with "sleep 1 && open -a JOSM.app"? But no, this wouldn't work on Linux. open(1) is a Mac OS X-specific application, the usual way to do this on Linux is to look at your argv[0] and start that with your argv[1..*] arguments. However with Java programs that wouldn't work since you need to worry about calling the right JVM and using the arguments to the JVM that were used to start the current program. I'm not familiar enough with the JVM but doesn't it support reloading itself with the current environment/arguments and the currently loaded .jar? Then this could probably be implemented portably. There's also probably prior art on this, check out http://google.com/codesearch _______________________________________________ josm-dev mailing list [email protected] http://lists.openstreetmap.org/listinfo/josm-dev
