Skip to content

Instantly share code, notes, and snippets.

@korkmazkadir
Last active February 14, 2018 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korkmazkadir/48210afca955705c8139260d084d00a0 to your computer and use it in GitHub Desktop.
Save korkmazkadir/48210afca955705c8139260d084d00a0 to your computer and use it in GitHub Desktop.
Server uygulaması main method
package simplechat;
import java.io.IOException;
import java.rmi.AccessException;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import simplechat.common.ChatServer;
import simplechat.common.Server;
/**
*
* @author Kadir Korkmaz
*/
public class ServerApp {
public static void main(String[] args) throws IOException, RemoteException, AccessException, AlreadyBoundException {
System.out.println("Creating RMI registry");
Runtime.getRuntime().exec("rmiregistry 2020");
LocateRegistry.createRegistry(2020);
System.out.println("Creating Server Object");
Server chatServer = new Server();
ChatServer serverStub = (ChatServer) UnicastRemoteObject.exportObject(chatServer, 0);
System.out.println("Registring Server object to registry");
// Bind the remote object's stub in the registry
Registry registry = LocateRegistry.getRegistry(2020);
registry.bind("ChatServerObject", serverStub);
System.out.println("Server ready...");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment