<b>Step 1: Implements the interface of Remote Server as SimpleCounterServer.Java</b>
public interface SimpleCounterServer extends java.rmi.Remote
{
public int getCount() throws java.rmi.RemoteException;
}
Compile it with javac SimpleCounterServer.java
<b>Step 2: ProdUCe the implement file SimpleCounterServerImpl.java as</b>
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
//
//
// SimpleCounterServerImpl
//
//
public class SimpleCounterServerImpl
extends UnicastRemoteObject
implements SimpleCounterServer
{
private int iCount;
public SimpleCounterServerImpl() throws java.rmi.RemoteException
{
iCount = 0;
}
public int getCount() throws RemoteException
{
return ++iCount;
}
public static void main(String args[])
{
System.setSecurityManager(new RMISecurityManager());
try
{
SimpleCounterServerImpl server = new SimpleCounterServerImpl();
System.out.println("SimpleCounterServer created");
Naming.rebind("SimpleCounterServer",server);
System.out.println("SimpleCounterServer registered");
}
catch(RemoteException x)
{
x.printStackTrace();
}