Ele fala que a conexão foi negada:
Erro na classe HelloClient -> Connection refused to host: cgt76219; nested exception is:
java.net.ConnectException: Connection refused: connect
Tentei escrever localhost ao invés do nome mas nada...
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Hello extends Remote {
String sayHello() throws RemoteException;
}
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class HelloImpl extends UnicastRemoteObject implements Hello {
private static final long serialVersionUID = 1L;
protected HelloImpl() throws RemoteException {
super();
}
@Override
public String sayHello() throws RemoteException {
return "Hello World";
}
}
import java.rmi.Naming;
public class HellClient {
public static void main(String args[]) {
// Cria e instala o security manager
// System.setSecurityManager (new RMISecurityManager () );
try {
Hello obj = (Hello) Naming.lookup("rmi://cgt76219/HelloServer");
System.out.println(obj.sayHello());
} catch (Exception e) {
System.out.println("Erro na classe HelloClient -> " + e.getMessage());
}
System.exit(0);
}
}
import java.rmi.Naming;
public class HelloServer {
public static void main(String args[]) {
// Cria e instala o Security Manager
// System.setSecurityManager(new RMISecurityManager());
try {
HelloImpl obj = new HelloImpl();
Naming.rebind("HelloServer", obj);
System.out.println("Hello Server pronto.");
} catch (Exception e) {
System.err.println("Erro na classe HelloServer " + e.getMessage());
}
}
}