import java.rmi.*;
import java.net.*;
import java.io.*;
public class RemClient {
public static void main(String[] args) {
try {
String host = (args.length > 0) ? args[0] : "10.11.47.121"; //从命令行读取远程主机名
//通过URL在远程主机上查找对象,并把它转化为本地接口Rem类型
Rem remObject=(Rem)Naming.lookup("rmi://" + host + "/Rem");
System.out.println(remObject.getMessage()); //调用远程对象的方法
} catch(RemoteException re) {System.out.println("RemoteException: " + re);
} catch(NotBoundException nbe) {System.out.println("NotBoundException: " + nbe);
} catch(MalformedURLException mfe){System.out.println("MalformedURLException:"+ mfe);
}}}