У меня есть простое приложение RMI, когда я пытался запустить его в локальной сети, оно не работает, мои классы следующие,
public interface HelloInterface extends Remote {
public String say() throws RemoteException;
}
public class Hello extends UnicastRemoteObject implements HelloInterface {
private String message;
public Hello(String msg) throws RemoteException {
message = msg;
}
@Override
public String say() throws RemoteException {
return message;
}
}
public class RmiServer {
public static void main(String[] argv) {
try {
Naming.rebind("Hello", new Hello("Hello, world!"));
System.out.println("Hello Server is ready.");
} catch (Exception e) {
System.out.println("Hello Server failed: " + e);
}
}
}
public class TestRMI {
public static void main(String[] argv) {
try {
HelloInterface hello = (HelloInterface) Naming.lookup("rmi://192.168.*.*/Hello");
System.out.println(hello.say());
} catch (Exception e) {
System.out.println("HelloClient exception: " + e);
}
try {
} catch (Exception e) {
e.printStackTrace();
}
}
}
, пожалуйста, помогите мне заставить это приложение работать в локальной сети.