StartRmiServer.java
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:2k
源码类别:

SNMP编程

开发平台:

C/C++

  1. /* $Id: StartRmiServer.java,v 1.2.2.3 2009/01/28 12:48:53 prathika Exp $ */
  2. /*
  3.  * @(#)rmigetbulk.java
  4.  * Copyright (c) 1996-2009 AdventNet, Inc. All Rights Reserved.
  5.  * Please read the COPYRIGHTS file for more details.
  6.  */
  7. import java.io.*;
  8. public class StartRmiServer
  9. {
  10.     public static void main(String [] args) {
  11.         Process process ;
  12.         Runtime rt;
  13.     
  14.         try
  15.         {
  16.             String command =null;
  17.             String command1 =null;
  18.             if( System.getProperty("os.name").endsWith("95"))
  19.             {
  20.                 command = "command.com /c  "+"rmiregistry";
  21.                 command1 = "command.com /c  "+"java -Djava.security.policy=SNMPRmi.policy com.adventnet.snmp.rmi.SnmpFactoryImpl";
  22.             }
  23.             else if( System.getProperty("os.name").endsWith("NT"))
  24.             {
  25.                 command = "cmd /c  "+"rmiregistry";
  26.                 command1 = "cmd /c  "+"java -Djava.security.policy=SNMPRmi.policy com.adventnet.snmp.rmi.SnmpFactoryImpl";
  27.             }
  28.             else 
  29.             {
  30.                 command = "rmiregistry";
  31.                 command1 = "java -Djava.security.policy=SNMPRmi.policy com.adventnet.snmp.rmi.SnmpFactoryImpl";
  32.             }
  33.             process = Runtime.getRuntime().exec(command);
  34.             // wait for some time till the RMI Registry is done.
  35.             try {
  36.                 Thread.sleep(1000);
  37.             } catch (Exception e)   {
  38.                 System.out.println ("Caught exception:" + e.getMessage());
  39.             }
  40.             System.out.println ("Started RMI Registry");
  41.             // Start the SNMP RMI Factory Impl.
  42.             process = Runtime.getRuntime().exec(command1);
  43.             System.out.println ("Started SNMP RMI Factory Impl. Waiting for requests from RMI Clients");
  44.         
  45.         }
  46.         catch(java.lang.SecurityException se)
  47.         {
  48.             System.out.println("RMI Server startup unsuccessfull:"+ se.toString());     
  49.         }
  50.         catch(IOException ex)
  51.         {
  52.             System.out.println("RMI Server startup unsuccessfull:"+ ex.toString());
  53.         }       
  54.     }
  55. }
  56.