banksystemserver.java
来自「java rmi技术实例」· Java 代码 · 共 53 行
JAVA
53 行
import java.io.IOException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.net.MalformedURLException;
public class BankSystemServer {
// public No-argument constructor
public BankSystemServer() {
}
public static void main(String args[]) {
new BankSystemServer();
BankManager bm = null;
try {
// Create a BankManager object
bm = new BankManagerImpl();
// Export it to RMI
UnicastRemoteObject.exportObject( bm );
} catch (RemoteException remoteException) {
System.err.println(
"Failure during object export to RMI: " +
remoteException);
}
// Register an external name for the service
try {
Naming.rebind("//localhost/BankSystem", bm);
} catch (RemoteException remoteException) {
System.err.println(
"Failure during Name registration: " +
remoteException);
} catch (MalformedURLException malformedException) {
System.err.println(
"Failure during Name registration: " +
malformedException);
}
System.out.println("Server started.");
System.out.println("Enter <CR> to end.");
try {
int i = System.in.read();
} catch (IOException ioException) {
}
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?