import java.net.InetAddress; import java.rmi.server.UnicastRemoteObject; import java.rmi.RemoteException; import java.rmi.RMISecurityManager; import java.rmi.Naming; public class RemoteMessage extends UnicastRemoteObject implements RemoteMessageInterface { public RemoteMessage() throws RemoteException { super(); } public void sendMessage(String message) { System.out.println(message); } public static void main(String[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } try { String name = "//" + InetAddress.getLocalHost().getHostName() + "/RemoteMessageInterface"; RemoteMessageInterface rmi = new RemoteMessage(); Naming.rebind(name, rmi); System.out.println("Remote Message bound"); } catch (Exception e) { System.err.println("RemoteMessage exception: " + e.getMessage()); } } }