首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

System.getProperty请问这段代码什么意思

2013-04-24 
System.getProperty请教这段代码什么意思代码是HornetQ中示例程序的client-side-load-balancing项目。publi

System.getProperty请教这段代码什么意思
代码是HornetQ中示例程序的client-side-load-balancing项目。


public class ClientSideLoadBalancingExample extends HornetQExample
{
   public static void main(final String[] args)
   {
      new ClientSideLoadBalancingExample().run(args);
   }
}
 
被调用代码如下

public abstract class HornetQExample
{
   protected static Logger log = Logger.getLogger(HornetQExample.class.getName());

   private Process[] servers;

   protected boolean failure = false;

   protected String serverClasspath;

   protected String serverProps;

   public abstract boolean runExample() throws Exception;

   private boolean logServerOutput;

   protected String[] configs;
   
   protected boolean runServer;

   protected void run(final String[] configs)
   {
      String runServerProp = System.getProperty("hornetq.example.runServer");
      String logServerOutputProp = System.getProperty("hornetq.example.logserveroutput");
      serverClasspath = System.getProperty("hornetq.example.server.classpath");
      runServer = runServerProp == null ? true : Boolean.valueOf(runServerProp);
      logServerOutput = logServerOutputProp == null ? false :  Boolean.valueOf(logServerOutputProp);
      serverProps = System.getProperty("hornetq.example.server.args");
      if (System.getProperty("hornetq.example.server.override.args") != null)
      {
         serverProps = System.getProperty("hornetq.example.server.override.args");
      }
      System.out.println("serverProps = " + serverProps);
      HornetQExample.log.info("hornetq.example.runServer is " + runServer);

      this.configs = configs;

      try
      {
         if (runServer)
         {
            startServers();
         }

         if (!runExample())
         {
            failure = true;
         }
         System.out.println("example complete");
      }
      catch (Throwable e)
      {
         failure = true;
         e.printStackTrace();


      }
      finally
      {
         if (runServer)
         {
            try
            {
               stopServers();
            }
            catch (Throwable throwable)
            {
               throwable.printStackTrace();
            }
         }
      }
      reportResultAndExit();
   }


这上面的System.getProperty(“*********”)让我迷惑好久,都不知道是什么意思!
不知道跟项目路径有没有关系。
Java
[解决办法]
这上面的System.getProperty(“*********”)让我迷惑好久,都不知道是什么意思!
取得系统的环境变量,例如System.getProperty("PATH") 会返回 PATH的值
[解决办法]
在jdk帮助文档中表示获取指定键指示的系统属性,参数表示系统属性的名称。

热点排行