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

📄 productclient.java

📁 core java第二卷源代码第三章。欢迎大家下载
💻 JAVA
字号:
 /**
   @version 1.01 2001-07-10
   @author Cay Horstmann
*/

import java.rmi.*;
import java.rmi.server.*;

/**
   This program demonstrates how to call a remote method
   on two objects that are located through the naming service.
*/
public class ProductClient
{  
   public static void main(String[] args)
   {  
      System.setProperty("java.security.policy", "client.policy");
      System.setSecurityManager(new RMISecurityManager());
      String url = "rmi://localhost/";
         // change to "rmi://yourserver.com/"
         // when server runs on remote machine
         // yourserver.com
      try
      {  
         Product c1 = (Product)Naming.lookup(url + "toaster");
         Product c2 = (Product)Naming.lookup(url + "microwave");
         System.out.println(c1.getDescription());
         System.out.println(c2.getDescription());
      }
      catch(Exception e)
      {  
         e.printStackTrace();
      }
   }
}

⌨️ 快捷键说明

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