import java.net.InetAddress; import java.rmi.RMISecurityManager; import java.rmi.Naming; public class LocalObject { public static void main(String args[]) { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } try { // assumes remote object is another process running on this machine String name = "//" + InetAddress.getLocalHost().getHostName() + "/RemoteMessageInterface"; RemoteMessageInterface rmi = (RemoteMessageInterface) Naming.lookup(name); rmi.sendMessage("Hello Remote Machine!!!"); } catch (Exception e) { System.err.println("LocalObject exception: " + e.getMessage()); e.printStackTrace(); } } }