dcsimg

How do I lookup a service in the RMI registry from an applet?

John Zukowski

For untrusted applets, the registry must be running on the web server from which it came. The necessary code follows:

String url getCodeBase().getHost();
url = "rmi://" + url + "/service";
Object obj = Naming.lookup(url);
You can then cast the returned object to whatever type you want.