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

📄 helloclient.java

📁 JAVA分布式程序学习的课件(全英文)
💻 JAVA
字号:
// A simple Jini client
// M. Liu, based on a code sample from "Noel's Nuggets"

import net.jini.core.entry.*;
import net.jini.core.lookup.*; 
import net.jini.core.discovery.*;    
import net.jini.lookup.entry.*; 
import com.sun.jini.lookup.*;
import java.rmi.*;

   class HelloClient{
      public static void main (String[] args){

        Entry[] attributes;
        LookupLocator lookup;  
        ServiceID id;       
        ServiceRegistrar registrar;
        ServiceTemplate template;
        HelloServerInterface helloServer;

        try {
          System.setSecurityManager 
             (new RMISecurityManager ());

          // Locate the Jini lookup service */           
          lookup = new LookupLocator("jini://localhost");
          // Find the ServiceRegistrar
          registrar  = lookup.getRegistrar();  
          // Look up the service           
          attributes = new Entry[1];
          attributes[0] = new Name ("HelloServer");
          template = new ServiceTemplate 
                        (null, null, attributes);
          helloServer = (HelloServerInterface) 
                           registrar.lookup(template);
          //Invoke a method of the service
          System.out.println(helloServer.sayHello());    
        } 
   
        catch (Exception ex) {
           ex.printStaceTrace( );
        }
      }
   }

⌨️ 快捷键说明

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