📄 lightbulbserver.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 + -