views:

88

answers:

1

I built a client server application using an IDL file for client server communication across the network. Both the client and server programs are in java. When the user enters exit, both the server and the client exit. However I'm unable to kill the nameserver process. I started the nameserver using the command

tnameserv -ORBInitialPort 1050

How can I kill the nameserver in the client or server programs( which are in java)?

+2  A: 

When you run the tnameserv you'll have to kill it via the kill command (linux,unix) or Ctrl+C (windows)

If on linux/unix, this should do the trick:

killall tnameserv

see http://java.sun.com/j2se/1.4.2/docs/guide/idl/tnameserv.html#stoppingnameserver

Edit:

If you want to issue the killall command from withing java use:

runtime.exec("killall tnameserv");

see http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html

Thoughts:

It seems odd to have started the tnameserv from outside of our program, and then try to kill it from within. (permission issues, other users using the nameserv, etc, etc.) Depending on your needs, why not start the tnameserv from within you app?

Lance Rushing
killall from a java program?
tuergeist
from the linux command line. same place you run the 'tnameserv -ORBInitialPort 1050' command from.
Lance Rushing
but the question was how to kill IN the client or server app (java)!
tuergeist
you *could* use runtime.exec() from inside java to run the killall command. However, now your program only works on systems that have killall (which might be ok). I'll edit my answer.
Lance Rushing
killall also only works if you have appropriate rights :)
tuergeist