• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I want to restart a class, basically, and need some assistance. :)

 
Adam S.
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Preface:

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.

Goal:

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.

Summary:

- 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

Thoughts:

This should be easily achieved with Runtime.getRuntime().exec but I have no clue how to redirect the streams.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic