I wrote a class to manage a server (which happens to be another class) that I run on my computer. It does stuff like start/restart/terminate the server. To launch it, I invoke the main method, of course, from a command line interface, so I can see all the junk it spews at me. Once launched, it creates an instance of the server and the magic begins.
Well, I plan to change the server's class files frequently, and almost never touch the computer running the server. So I've written a way to send the new class files to the computer and overwrite the old ones. The problem is, since I can't for the life of me figure out dynamic class loading, I need to restart the server manager after I update the class files to update the server.
- I need to restart a java application from within java - Since this is going to run on Linux without a window manager, I have to keep the same System.in and System.out
This should be easily achieved with Runtime.getRuntime().exec but I have no clue how to redirect the streams.
Sounds like ServerManager needs a way to tell a running server to stop, and then use exec to start a new one. I did the shut down part with my own Wiki. A special command-line program opens a socket as a client and sends a "shut down" command. It actually fakes logging on and posting a form, but you could make the server understand a shorter, simpler command from the manager. Now you need a way to tell the manager to stop and restart the server. I'd just do the same thing again - open a serversocket in the manager and accept a special request to recycle the server.
Hope that made sense.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
subject: I want to restart a class, basically, and need some assistance. :)