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

📄 banksystemserver.java

📁 java rmi技术实例
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -