HelloClient.java
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:1k
源码类别:
Java编程
开发平台:
Java
- package bible.rmi.example1;
- import weblogic.rmi.*;
- import weblogic.common.*;
- /**
- * HelloClient finds the HelloServer via a Naming lookup and calls
- * the HelloServer's remote method sayHello.
- */
- public class HelloClient {
- /**
- * Logical name used to look up the remote HelloServer.
- */
- public final static String SERVERNAME = "rmi://localhost:7001/HelloServer";
- /**
- * Does a Naming lookup for the HelloServer and says hello.
- * @param argv
- */
- public static void main(String[] argv) {
- try {
- HelloInterface obj = (HelloInterface) Naming.lookup(SERVERNAME);
- System.out.println("Successfully connected to HelloServer.");
- String message = obj.sayHello();
- System.out.println(message);
- } catch (Throwable t) {
- t.printStackTrace();
- System.exit(-1);
- }
- }
- }