Nils’ Geek Blog

Stuff that doesn’t matter

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 ! :)

Bookmark this:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • YahooMyWeb
  • Fark
  • Reddit
  • NewsVine
  • Spurl
  • blogmarks
  • BlinkList
Listen to this podcast Listen to this podcast

Tags: , , Trackback URI

No comments yet. Be the first.

Related posts

Flash Player 9 released
Buying a new digicam

Leave a reply