Last active
February 14, 2018 12:44
-
-
Save korkmazkadir/48210afca955705c8139260d084d00a0 to your computer and use it in GitHub Desktop.
Server uygulaması main method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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