//package examples.hello; import java.awt.*; import java.rmi.*; import java.net.*; import java.util.*; import java.lang.*; import java.io.*; public class HelloClient { String message = ""; // The init method begins the execution of the applet on the client // machine that is viewing the Web page containing the reference // to the applet. Hello obj; public HelloClient(String name) { String str; boolean flag = true; try { // Looks up the server using the name server on the host that // the applet came from. obj = (Hello)Naming.lookup("rmi://localhost/HelloServer"); // Calls the sayHello method on the remote object. message = obj.sayHello(); System.out.println("Returned: " + message); PlayerImpl player = new PlayerImpl(name, obj); while(flag){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); str = br.readLine(); obj.send(player.name + ": " + str); }; } catch (RemoteException e) { System.out.println("HelloApplet RemoteException caught"); } catch (NotBoundException e) { System.out.println("HelloApplet NotBoundException caught"); } catch (MalformedURLException e) { System.out.println("HelloApplet MalformedURLException caught"); } catch (IOException e) { System.out.println("HelloApplet IOException caught"); } System.exit(0); } public static void main(String args[]) { //init(); if(args.length != 1) { System.err.println("Usage: HelloClient "); System.exit(1); }; HelloClient client = new HelloClient(args[0]); }; };