当前位置: 首页 > 工具软件 > RMIIO > 使用案例 >

Java API——RMIIO入门教程(3)远程流传输示例之RMIIO服务器端源码

万嘉石
2023-12-01

RMI Server端。这个其实跟RMIIO关系不大。


package com.sinosuperman.rmiio2;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;


public class RmiioServer2 {
	
	public static void main(String[] args) {
		
		try {
			/* Create a Remote object. */
			RmiioService2 testRMIIO = new RmiioServiceImpl2();
			
			/* Create a registry object with 1235 port. */
			LocateRegistry.createRegistry(2234);
			
			/* Register the Remote object to RMI registry server, and name it as testrmi. */
			Naming.bind("rmi://localhost:2234/testrmiio", testRMIIO);
			
			System.out.println("注册远程对象成功");
			
		} catch (RemoteException e) {
			System.out.println("远程对象创建异常");
			e.printStackTrace();
		} catch (MalformedURLException e) {
			System.out.println("URL畸形异常");
			e.printStackTrace();
		} catch (AlreadyBoundException e) {
			System.out.println("重复绑定异常");
			e.printStackTrace();
		}
	}
}



原文链接: http://blog.csdn.net/poechant/article/details/7031737

转载于:https://my.oschina.net/chen106106/blog/50230

 类似资料: