ClientTest.java



/** Messageの通信のテスト */
import java.net.*;
import java.rmi.*;
public class ClientTest {

  /** 起動時に呼び出されるメソッド */
    public static void main( String argv[] ) {

        System.setSecurityManager( new RMISecurityManager() );
        try {
            String serverName = "rmi://" + argv[0] + "/TalkServer";
            InetAddress host = InetAddress.getLocalHost();
            String hostName = host.getHostName();
            String receiverName = "rmi://" + hostName + "/MessageReceiver";
            SimpleMessageReceiver receiver
              = new SimpleMessageReceiver( serverName, receiverName );
            SimpleMessageSender sender
              = new SimpleMessageSender( serverName, hostName );
            sender.inputLoop();
         }
         catch( Exception e ) {
            System.err.println( "Error:" + e.toString() );
            System.exit(-1);
         }
    }
}