Exception in thread "main" java.rmi.NotBoundException: RMIService
时间: 2023-12-19 13:32:02 浏览: 97
启动tomcat时 错误: 代理抛出异常 : java.rmi.server.ExportException: Port already in use: 1099的解决办法
5星 · 资源好评率100%
```java
package com.huawei.rmi;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Client {
public static void main(String[] args) throws RemoteException, NotBoundException {
Registry registry = LocateRegistry.getRegistry("localhost", 1099);
HelloRegistryFacade hello = (HelloRegistryFacade) registry.lookup("HelloRegistryFacade");
String response = hello.helloWorld("Alice");
System.out.println("Response from RMI server: " + response);
}
}
```
```java
package com.huawei.openvector.zk;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Client {
public static void main(String[] args) throws RemoteException, NotBoundException {
Registry registry = LocateRegistry.getRegistry("localhost", 1099);
HelloService helloService = (HelloService) registry.lookup("HelloService");
String response = helloService.sayHello("Alice");
System.out.println("Response from RMI server: " + response);
}
}
```
阅读全文