0

I am working on a plugin for the Serversoftware Bukkit which should restart it. So I have added the main Function which checks for the right arguments and then starts Bukkit. But before it starts Bukkit it should wait for Bukkit to shutdown before I start it again. I know I could add a timeout but I hope there is a better way. So does anybody know how to do that?

Max Jöhnk
  • 163
  • 1
  • 10

2 Answers2

0

One way would be to check the os with System.getProperty("os.name"); and run the ad hoc command for that specific platform (for example: Linux and Windows).

Community
  • 1
  • 1
assylias
  • 321,522
  • 82
  • 660
  • 783
  • 1
    Also thought about that but unsure whether i will find the right process. The Idea was to add the process itself or the pid as an Argument but if you are running the client and the server on windows, they are both called java.exe. – Max Jöhnk Aug 01 '12 at 22:52
0

When you start multiple java processes they all seem to have the same identifiers, which seems to be your problem. "differentiating" the processes is your problem, not killing them.

So either you could create the process yourself programatically, and thus be able to note the PID that is used for the process. Then killing it would be VERY simple: http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html

Another idea would be to use JPS to get information on all the java processes. A simple sudo algorithm is discussed here: http://bluepedia.blogspot.com/2008/11/jps-differentiate-between-multiple-java.html

Hope I could be of some help..

While-E
  • 1,527
  • 2
  • 20
  • 37