~/ learn/ comp-348/ cards/ Exporting and the registry
1 of 5

Type the server-side export and publish: exportObject, createRegistry, rebind

Type the server-side export and publish: exportObject, createRegistry, rebind

Answer

PrimeService stub = (PrimeService) UnicastRemoteObject.exportObject(impl, 0); Registry registry = LocateRegistry.createRegistry(1099); registry.rebind("PrimeService", stub);

Port 0 means "any free port", and the stub carries whichever one was chosen. createRegistry runs the name service inside this JVM — the modern form, with no separate rmiregistry process. rebind, not bind, so a restart does not throw AlreadyBoundException.

JDK javadoc java.rmi.server.UnicastRemoteObject; java.rmi.registry.LocateRegistry

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/553eee31-4bed-4fa4-a097-d4a896914901/flashcard utf-8 LF