Java获取系统属性

1、System类

   The System class contains several useful class fields and methods. It cannot be instantiated.

   Among the facilities provided by the System class are standard input, standard output, and error output streams; access to externally defined properties and environment variables; a means of loading files and libraries; and a utility method for quickly copying a portion of an array.

   大意是:System类中包含了一些有用的字段和方法,它不能被实例化。System类中提供了一些基础的功能,它们是标准输入流、输出流、错误流;访问外部定义的属性和环境变量;加载文件和类库的一种方式;以及一个有用的快速复制数组中的部分内容的方法。


2、环境变量和系统属性

   (1)环境变量是指系统环境变量,系统属性是指当前JVM专用的,它可能与环境变量有交集,但不会完全相同。

   (2)获取环境变量用getenv()方法

       public static Map<String,Stringgetenv()

      获取系统属性用getProperties()方法

       public static Properties getProperties()

   (3)JVM在启动的时候,会将环境变量装换到系统属性里面。可以在tomcat的bin目录下的catalina.bat文件中发现一些预定义的必须的环境变量








本文转自    手不要乱摸      51CTO博客,原文链接:http://blog.51cto.com/5880861/1395985







上一篇:java系统学习指导与规划


下一篇:6hutool实战:DateUtil(时间工具类)-时间偏移量获取