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?

Tech Stuff - Corey Dahl
These days, we want all of our information available on all of our devices.  Am I right or am I right? We love to log into another computer (in this case we're logging into Google) and all of our gmail, contacts, calendars are available.
[Review] - Heartful silky lipstick
This is actually an item I ordered looooong time ago (together with THIS ) but due to bad picture quality (mostly) and very little time to retake some, I had to delay this review.  Anyways!