helloserver.java

来自「100多M的J2EE培训内容」· Java 代码 · 共 43 行

JAVA
43
字号
package bible.rmi.example1;import weblogic.rmi.*;import java.rmi.*;/** * HelloServer is a remote server that can registers itself via Naming and * wait for clients to call its remote method, sayHello. */public class HelloServer implements HelloInterface {  /**   * When remote client's call say hello, respond with a greeting, also   * pushs a message to standard out that this method has been called.   * @returns A greeting from the implementing server.   * @throws RemoteException   */  public String sayHello() throws java.rmi.RemoteException {    System.out.println("HelloServer.sayHello() has been remotely invoked.");    return "Hello, remote world!!";  }  /**   * Main method instanciates a server, registers itself with a bind, and   * waits for clients to call the remote method sayHello.   * @param argv   */  public static void main(String[] argv) {    try {      HelloServer obj = new HelloServer();      weblogic.rmi.Naming.rebind("HelloServer", obj);      System.out.println("HelloServer was created and bound in the registry "                         + "to the name HelloServer");    } catch (Exception e) {      System.out.println("HelloServer error: " + e.getMessage());      e.printStackTrace();    }  }}

⌨️ 快捷键说明

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