Search in sources :

Example 1 with HelloService

use of yyl.example.basic.rmi.api.HelloService in project yyl_example by Relucent.

the class HelloClient method main.

public static void main(String[] args) {
    try {
        // 在RMI服务注册表中查找名称为RHello的对象,并调用其上的方法
        HelloService service = (HelloService) Naming.lookup("rmi://localhost:8888/hello");
        System.out.println(service.hello());
        System.out.println(service.hello("I'm the king of the world!"));
    } catch (NotBoundException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) NotBoundException(java.rmi.NotBoundException) HelloService(yyl.example.basic.rmi.api.HelloService) RemoteException(java.rmi.RemoteException)

Aggregations

MalformedURLException (java.net.MalformedURLException)1 NotBoundException (java.rmi.NotBoundException)1 RemoteException (java.rmi.RemoteException)1 HelloService (yyl.example.basic.rmi.api.HelloService)1