⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lightbulbserver.java

📁 Java网络编程与分布式计算, 主要分析java网络各方面的编程, 提供许多实用安全
💻 JAVA
字号:
import java.rmi.*;
import java.rmi.server.*;

// Chapter 11, Listing 3
public class LightBulbServer 
{
	public static void main(String args[])
	{
		System.out.println ("Loading RMI service");

		try
		{
			// Load the service
			RMILightBulbImpl bulbService = new RMILightBulbImpl();

			// Examine the service, to see where it is stored
			RemoteRef location = bulbService.getRef();
			System.out.println (location.remoteToString());

			
			// Check to see if a registry was specified
			String registry = "localhost";
			if (args.length >=1)
			{
				registry = args[0];
			}

			// Registration format //registry_hostname (optional):port /service
			String registration = "rmi://" + registry + "/RMILightBulb";
			
			// Register with service so that clients can find us
			Naming.rebind( registration, bulbService );

		}
		catch (RemoteException re)
		{
			System.err.println ("Remote Error - " + re);
		}
		catch (Exception e)
		{
			System.err.println ("Error - " + e);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -