原来我一直都混淆了system properties和environment properties。今天终于搞清楚了,记录一下
一、system properties
这里的system指的不是OS,而是JVM system
system properties通过
System.getProperty(key);
来获取
而设置的方法主要有3种:
第一种是JVM内置的,包括java.vm.version等,通过以下代码可以看到全集
Properties props = System.getProperties();
Set<Object> keys = props.keySet();
for(Object key:keys){
System.out.println(key);
}
第二种是在启动时,通过-D参数设置的
第三种则是通过
System.setProperty(key, value);
来设置
二、environment properties
这里的environment指的才是操作系统
获取这种参数的方法是
System.getenv();
在操作系统里设置的环境变量,可以通过这个方法取到
通过以下代码,可以取到全集
Map<String, String> env = System.getenv();
Set<String> keys = env.keySet();
for (String key : keys) {
System.out.println(key);
}
分享到:
相关推荐
The Logistic map is a classical chaotic system and has been used as a chaotic cipher in the real number field. This inevitably leads to the degradation of finite precision under the computer ...
安装完JDK以后,需要配置Java的系统的全局变量。一共需要加三个: JAVA_HOME:JDK的安装路径 Path:JAVA的二进制文件路径,就是JDK的安装...在System Properties的Advanced选项卡里,点击Environment Variables按键。
Analysis of Robotic System Motion in SimMechanics and MATLAB GUI Environment。 Robots present considerably complicated electromechanical systems with mutual interactions of robot mechanics and ...
弹簧属性解密器 使用库透明地解密要在Spring环境中使用的属性值。 如何使用 Gradle依赖 runtime('eu.hinsch:...在可以定义的任何地方定义任何spring环境属性(application * .properties / yaml,system,environment
Applications of the new system are run in a chroot environment and working together with the Android platform. All changes made on the device are reversible, i.e. the application and components can ...
%yourusername%和System variables 2.4.1-单击Path 2.4.2-单击New 2.4.3-添加以下路径 C:\Users\%yourusername%\AppData\Local\Programs\Python\Python37 C:\Users\%yourusername%\AppData\Local\Programs\Python\...
Support sources from JSON, XML, YAML, HOCON, TOML, properties, map, command line and system environment out of box. Cascading. Config can fork from another config by adding a new layer on it. Each ...
networked environment. A service-oriented network socket takes a high-level description of a service and opportunistically connects to the best provider of that service in the changing characteristics...
LinqConnect is a fast and easy-to-use ORM solution, developed ...The behaviour is changed: the TINYINT(1) data type is now used for the columns which correspond to the System.Boolean properties (MySQL)
A theoretical framework which is gaining more and more support considers the properties of the visual system to be reflections of the statistical structure of natural images because of evolutionary ...
1. Summarize the DXE phase and its purpose, functions, properties, attributes, and components * Identify the responsibilities of the DXE phase 2. Describe events and their role in the DXE phase 3. ...
and more support considers the properties of the visual system to be reflections of the statistical structure of natural images because of evolutionary adaptation processes. Another motivation for ...
captures general program properties (like execution frequency of methods or basic blocks) may be useful, but does not capture sufficient information about the execution platform. Machine-level ...
Chord protocol and proves several of its properties, while Section 5 presents extensions to handle concurrent joins and failures. Sec- tion 6 demonstrates our claims about Chord’s performance ...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Set the FolderBrowser dialog properties With (FolderBrowserDialog1) .Description = ...
System Requirements Supported Operating Systems: Windows 2000, Windows XP, Windows Vista Supported Languages: VB, C#, C++, other COM-accessible languages Documentation Documentation for ...
System Namespace 153 File I/O 155 Drawing 156 Printing 157 Common Type System 158 Type Casting 160 Garbage Collection 163 Object Allocation/Deallocation 164 Close/Dispose 165 Summary 166 ...
Linux System Administrator Guide Version0.9 <br>Table of Contents About This Book....................................................................................................................
Canvas Pocket Reference provides both a tutorial that covers all of the element's features with plenty of examples and a definitive reference to each of the Canvas-related ... and properties....