sampleclient.java

来自「java rmi例子」· Java 代码 · 共 41 行

JAVA
41
字号
//---------------------------------------------------------------// File: SampleClient.java//---------------------------------------------------------------import java.rmi.*;import java.rmi.server.*;public class SampleClient  {   public static void main(String[]  args)   {      // set the security manager for the client      System.setSecurityManager(new RMISecurityManager());      //get the remote object from the registry      try        {          System.out.println("Security Manager loaded");          String url = "//localhost/SAMPLE-SERVER";          SampleServer remoteObject = (SampleServer)Naming.lookup(url);          System.out.println("Got remote object");          //narrow the object down to a specific one          //System.out.println("Location: " + System.getProperty("LOCATION"));          // make the invocation        }      catch (RemoteException exc)        {          System.out.println("Error in lookup: " + exc.toString());        }      catch (java.net.MalformedURLException exc)        {          System.out.println("Malformed URL: " + exc.toString());        }      catch (java.rmi.NotBoundException exc)        {          System.out.println("NotBound: " + exc.toString());        }   }}

⌨️ 快捷键说明

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