December 10th 2005
Java RMI - a frustrating business!
I’ve been working on a development project the last week. Everything was proceeding as planned until we found out that we needed to use Java RMI. After 2 days of biting my tongue and eating candles I finally got a simple “Hello World” example working. It’s nice to have connections from uni
Thanks to Arild Sandven for helping us on the right track. For everybody struggeling with implementing RMI try running the registry from within the JVM. Here’s the code:
public interface MyRemoteObjectInterface extends Remote {
void someMethod() throws RemoteException;
}
//Serverside
Registry reg = LocateRegistry.createRegistry(1099);
MyRemoteObject remote = new MyRemoteObject();
reg.rebind(”RemoteObject”, remote);
// The MyRemoteObject class must extend UnicastRemoteObject and implement MyRemoteObjectInterface (which extends Remote)
//Clientside
String host = “localhost”;
int rmiPort = 1099;
lookUpName= “rmi://” + _host + “:” + rmiPort + “/RemoteObject”;
MyRemoteObjectInterface = (MyRemoteObjectInterface) Naming.lookup(lookUpName);
Hope this helps someone!
Back to the code !
Listen to this podcast
Tags: programming, java, rmi Trackback URI












