I am trying to make a Java program which will run several other unrelated Java programs, specifically a Minecraft server. Currently, I am trying to work out how to end a java.lang.Process gracefully.
This is the code for my spawner program: http://dl.dropbox.com/u/26746878/SpawnerSource/Main.java.txt
And this is the code for the program which is spawned: http://dl.dropbox.com/u/26746878/SpawnerSource/Tester.java.txt
What I do is run my spawner program. Then, after a few seconds, I terminate it with Ctrl-C. What I want to see is my program output 'Shutting Down' followed by 'Ending'. I also want to see a file 'test.txt'. What I actually see is only 'Shutting Down', with no 'Ending' nor 'test.txt'
I believe the problem is that Process.destroy() is forcefully ending the process without letting the shutdown hooks run.
Is there an alternative to Process.destroy() which will exit the process gracefully (ie: as if I had pressed Ctrl-C)?