How to make an RMI server multi-client program without registerting clients

I have a RMI server which a number of clients connect to. When a client registers a change, the server reacts and instructs all clients to make a change.

I have been looking into a number of hello world RMI examples, but none of them addresses how to persist a connection back to the client from the server.

What i would like to achieve is something along these lines: Server is registered on the rmiregistry. Client 1 connects to the server and calls a method on the server. Client 2 connects to the server and calls a method on the server. The server sends the change from client2 to client1.

Java rmi example program with code - SlideShare
15 Mar 2013 ... Steps to run this programs: First of all put these four programs insidebin folder of
JDK. As an example suppose our JDK folder isinside java ...

How does one achieve this without registering every client as a server?

EDIT: After looking at a couple of excellent ansvers (flatter flatter) i am running into the following exception java.rmi.StubNotFoundException: Stub class not found: thegame.connectivity.GameClient_Stub; nested exception is:

java.lang.ClassNotFoundException: thegame.connectivity.GameClient_Stub at sun.rmi.server.Util.createStub( at sun.rmi.server.Util.createProxy( at sun.rmi.server.UnicastServerRef.exportObject( at java.rmi.server.UnicastRemoteObject.exportObject( at java.rmi.server.UnicastRemoteObject.exportObject( at thegame.connectivity.GameClient.bind( at at thegame.connectivity.GameClient.main( Caused by: java.lang.ClassNotFoundException: thegame.connectivity.GameClient_Stub at$ at$ at Method) at at java.lang.ClassLoader.loadClass( at sun.misc.Launcher$AppClassLoader.loadClass( at java.lang.ClassLoader.loadClass( at java.lang.Class.forName0(Native Method) at java.lang.Class.forName( at sun.rmi.server.Util.createStub( ... 7 more

On this class

public class GameClient extends Thread implements Remote, Client, ModelChangeListener<Client>{ private static final long serialVersionUID = -394039736555035873L; protected Queue<GameModelEvent> queue = new ConcurrentLinkedQueue<GameModelEvent>(); public GameClient(){ } public static void main(String[] args){ GameClient client = new GameClient();; } protected void bind(){ System.setProperty("java.rmi.server.codebase","file:bin/"); try { Registry registry = LocateRegistry.getRegistry(); Client c = (Client)UnicastRemoteObject.exportObject(this); Server stub = (Server) registry.lookup("Server"); stub.registerClient(c); } catch (RemoteException | NotBoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void run() {; bind(); while(!Thread.interrupted()){ System.out.print("."); GameModelEvent event = queue.poll(); while(event != null){ System.out.println(event); event = queue.poll(); } try { Thread.sleep(100); } catch (InterruptedException e) { return; } } } ...

It works well when i comment out the UnicatRemoteObject and just pass null as a parameter. So there is a connection and everything is running. But no stub... Commenting out the codebase has no effect either. The codebase works fine on the server.

Creating a Client Program (The Java™ Tutorials > RMI)
This RMI Java tutorial describes the Java RMI system. It walks ... Two separate
classes make up the client in our example. ... Finally, the program prints the result

Any ideas on what is wrong?

Powershop Labs
There are three certain things in life; tax, death, and higher winter power bills. There’s not much we can do about the first two, but at Powershop we’re committed to helping you keep your power costs as low as possible.
Battery Power Gives Deliverymen a Boost, at a Cost
Todd Heisler/The New York TimesElectric bikes have made life easier for the Chinese food delivery business in New York, but they are illegal to use on city streets. It’s almost impossible to walk a block or two in Manhattan and not spy a Chinese-food deliveryman on a bicycle.
10 ways to earn extra cash
When Claire Burnett's husband was made redundant, she realised that she needed to help support her family financially. "Soon after my husband lost his job, we unexpectedly got custody of my two stepchildren," she said.