- 论坛徽章:
- 19
|
- package com.fangzhaoguo.RMI;
- import java.net.InetAddress;
- import java.net.MalformedURLException;
- import java.net.UnknownHostException;
- import java.rmi.Naming;
- import java.rmi.RemoteException;
- import java.rmi.registry.LocateRegistry;
- public class Server
- {
- public final static int port = 4321;
- public static void main(String[] args)
- {
- try
- {
- Service service = new Service();
- LocateRegistry.createRegistry(port);
- Naming.rebind("//" + InetAddress.getLocalHost().getHostAddress()
- + ":" + port + "/database", service);
- } catch (RemoteException | MalformedURLException | UnknownHostException e)
- {
- e.printStackTrace();
- }
- }
- }
复制代码 服务器端主程序,用于绑定接口 |
|