File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes I want to restart a class, basically, and need some assistance. :) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "I want to restart a class, basically, and need some assistance. :)" Watch "I want to restart a class, basically, and need some assistance. :)" New topic
Author

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

Adam S.
Greenhorn

Joined: Jun 02, 2004
Posts: 3
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

Joined: Jan 29, 2003
Posts: 8791
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I want to restart a class, basically, and need some assistance. :)