Prev: IllegalAccessError - Super/sub-types loaded with different classloaders
Next: "This method blocks until..." means what exactly?
From: Hakan on 25 Jul 2010 14:22 Which is the best way to get the process ID on Windows after spawning a Process object with the Runtime.getRuntime.exec method? A search on the web says that Java has no direct way of doing it, and then several different ways to do it are presented. Thanks. -- Newsoffice.de - Die Onlinesoftware zum Lesen und Schreiben im Usenet Die Signatur l��t sich nach Belieben anpassen ;-)
From: John B. Matthews on 25 Jul 2010 21:45 In article <1280082152.94(a)user.newsoffice.de>, Hakan <H.L(a)softhome.net> wrote: > Which is the best way to get the process ID on Windows after spawning > a Process object with the Runtime.getRuntime.exec method? A search on > the web says that Java has no direct way of doing it, and then > several different ways to do it are presented. Thanks. On my platform , I've used `ps` and `awk` from a bash script to do this; jps looks a little more portable, although the format is subject to change in future releases: What criteria are you using to evaluate the approaches you've examined so far? -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews>
From: Arne Vajhøj on 25 Jul 2010 21:59 On 25-07-2010 14:22, Hakan wrote: > Which is the best way to get the process ID on Windows after spawning a > Process object with the Runtime.getRuntime.exec method? A search on the > web says that Java has no direct way of doing it, and then several > different ways to do it are presented. Thanks. Write something that start a process via JNI and CreateProcess. It is not portable, but your problem definition is not portable. Arne
From: Owen Jacobson on 26 Jul 2010 00:39
On 2010-07-25 21:59:23 -0400, Arne Vajh�j said: > On 25-07-2010 14:22, Hakan wrote: >> Which is the best way to get the process ID on Windows after spawning a >> Process object with the Runtime.getRuntime.exec method? A search on the >> web says that Java has no direct way of doing it, and then several >> different ways to do it are presented. Thanks. > > Write something that start a process via JNI and CreateProcess. > > It is not portable, but your problem definition is not portable. > > Arne Seconding this; you need to use platform-specific features to fiddle with process control beyond "start a process" and "wait for it to end", so you might as well use a language suited to the target platform. Use ..Net, not Java, if you need to do this on Windows. -o |