1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| package Server; import java.rmi.registry.LocateRegistry; import java.rmi.Naming; import InterFace.*; import java.rmi.server.UnicastRemoteObject;
public class MyRMIServer {
public static void main(String[] args) throws Exception {
try { String serverIP = "106.14.2.163"; System.setProperty("java.rmi.server.hostname", serverIP); LocateRegistry.createRegistry(6789); String name ="rmi://127.0.0.1:6789/BookSystem"; BookSystemInfo engine = new BookSystem(); BookSystemInfo skeleton = ( BookSystemInfo) UnicastRemoteObject.exportObject(engine, 5678); System.out.println("Registering BookSystem Object"); Naming.bind(name,skeleton); } catch (Exception e) { System.err.println("Exception:" + e); e.printStackTrace(); } } }
|