/* A client applet that uses RMI to call a method in an RMI * server called "HelloServer". * This requires the rmiregistry and the rmi implementation server * to be running on the web host machine of this applet. */ import java.awt.*; import java.rmi.*; public class HelloApplet extends java.applet.Applet { String message = ""; public void init() { try { /* get a reference to the remote object called "HelloServer" * from the naming registry */ Hello obj = (Hello)Naming.lookup("//" + getCodeBase().getHost() + "/HelloServer"); /* call a method from the server!!!! */ message = obj.sayHello(); } catch (Exception e) { System.out.println("HelloApplet exception: " + e.getMessage()); e.printStackTrace(); } } public void paint(Graphics g) { g.setFont(new Font("Dialog", Font.BOLD, 18)); g.drawString(message, 25, 50); } }