RMI java Hello world
Уже 2 часа сижу, не могу даже сервер сделать (
run:
Server exception: java.rmi.ConnectException: Connection refused to host: 192.168.1.4; nested exception is:
java.net.ConnectException: Connection refused: connect
package helloworldpackage;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface HelloWorld extends Remote {
String getMessage() throws RemoteException;
}
package helloworldpackage;
public class HelloWorldImpl implements HelloWorld {
private String Message = "Hello World";
public HelloWorldImpl() {
}
@Override
public String getMessage() {
return Message;
}
}
package helloworldpackage;
import java.rmi.registry.*;
import java.rmi.server.*;
public class HelloWolrdServer {
public static void main(String[] args) {
try {
HelloWorldImpl obj = new HelloWorldImpl();
HelloWorld stub = (HelloWorld) UnicastRemoteObject.exportObject(obj, 0);
Registry registry = LocateRegistry.getRegistry();
registry.rebind("rmi://localhost/HelloWorld", stub);
System.out.println("Server ready");
} catch (Exception e) {
System.out.println("Server exception: " + e.toString());
}
}
}