Я новичок в Java и системе RMI. Я следую руководству, но не понимаю, почему я продолжаю получать следующие ошибки [1] [1]: https://i.stack.imgur.com/xeYTn.png Я прикрепил код (взят непосредственно из руководства здесь: https://docs.oracle.com/javase/1.5.0/docs/guide/rmi/hello/hello-world.html)
Я пробовал:
- удаление любых строк с помощью 'package'
- изменение переменных пути к классам
- переустановка java и javac
- установка пути к классам в команде 'rmiregistry &'
Любая помощь будет принята с благодарностью
edit: Упс, забыл прикрепить код. Здравствуйте. java
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Hello extends Remote {
String sayHello() throws RemoteException;
}
Клиент. java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Client {
private Client() {
}
public static void main(String[] args) {
String host = (args.length < 1) ? null : args[0];
try {
Registry registry = LocateRegistry.getRegistry(host);
Hello stub = (Hello) registry.lookup("Hello");
String response = stub.sayHello();
System.out.println("response: " + response);
} catch (Exception e) {
System.err.println("Client exception: " + e.toString());
e.printStackTrace();
}
}
}
Сервер. java
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class Server implements Hello {
public Server() {
}
public String sayHello() {
return "Hello, world!";
}
public static void main(String args[]) {
try {
Server obj = new Server();
Hello stub = (Hello) UnicastRemoteObject.exportObject((Remote) obj, 0);
// Bind the remote object's stub in the registry
Registry registry = LocateRegistry.getRegistry();
registry.bind("Hello", stub);
System.err.println("Server ready");
} catch (Exception e) {
System.err.println("Server exception: " + e.toString());
e.printStackTrace();
}
}
}