目录
一、Java之System
1、getProperty()
一、Java之System
1、getProperty()
System.getProperties()可以确定当前的系统属性,返回值是一个Properties;
System.load(String filename)等同于:System.getProperties().load(String filename)它们的作用是可以从作为动态库的本地文件系统中以指定的文件名加载代码文件。
System.setProperties(Properties propes)将系统属性设置为Properties参数;
System.setProperties(String key,String value)等同于System.getProperties().setProperties(String key,String value):设置指定键指示的系统属性
键相关值的描述
java.version Java 运行时环境版本
java.vendor Java 运行时环境供应商
java.vendor.url Java 供应商的 URL
java.home Java 安装目录
java.vm.specification.version Java 虚拟机规范版本服务器托管网
java.vm.specification.vendor Java 虚拟机规范供应商
java.vm.specification.name Java 虚拟机规范名称
java.vm.version Java 虚拟机实现版本
java.vm.vendor Java 虚拟机实现供应商
java.vm.name Java 虚拟机实现名称
java.specification.version Java 运行时环境规范版本
java.specification.vendor Java 运行时环境规范供应商
java.specification.name Java 运行时环境规范名称
java.class.version Java 类格式版本号
java.class.path Java 类路径
java.library.path 加载库时搜索的路径列表
java.io.tmpdir 默认的临时文件路径
java.compiler 要使用的 JIT 编译器的名称
java.ext.dirs 一个或多个扩展目录的路径
os.name 操作系统的名称
os.arch 操作系统的架构
os.version 操作系统的版本
file.separator 文件分隔符(在 UNIX 系统中是“/”)
path.separator 路径分隔符(在 UNIX 系统中是“:”)
line.separator 行分隔符(在 UNIX 系统中是“/n”)
user.name 用户的账户名称
user.home 用户的主目录
user.dir 用户的当前工作目录
Java代码
public class TestSystemGetSet {
static{
System.setProperty("DB", "mysql");//可以作为全局变量,在任何地方使用
}
public static void main(String[] args) {
System.out.println(System.getProperty("os.version"));
System.out.println(System.getProperty("java.library.path"));
System.out.println(System.getProperty("DB"));
Properties properties = System.getProperties();
for (Object key : properties.keySet()) {
System.out.println("key=" + key + "tttvalue=" + properties.get(key));
}
}
}
输出结果
10.0
C:Program FilesJavajdk1.8.0_202bin;C:WindowsSunJavabin;C:Windowssystem32;C:Windows;C:Program Files (x86)Common FilesOracleJavajavapath;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:WindowsSystem32OpenSSH;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program FilesNVIDIA CorporationNVIDIA NvDLISR;"C:Program FilesJavajdk1.8.0_202bin;C:Program FilesJavajdk1.8.0_202jrebin;";C:Program FilesGobin;C:Program FilesGobin;C:Program FilesPuTTY;C:Program FilesGitcmd;C:Program FilesTortoiseGitbin;C:Program FilesMicrosoft VS Codebin;C:UsersAdministratorAppDataLocalMicrosoftWindowsApps;C:UsersAdministratorgobin;C:Program FilesJetBrainsGoLand 2023.2bin;;C:Program FilesJetBrainsIntelliJ IDEA 2023.2.3bin;;.
mysql
key=java.runtime.name value=Java(TM) SE Runtime Environment
key=sun.boot.library.path value=C:Program FilesJavajdk1.8.0_202jrebin
key=java.vm.version value=25.202-b08
key=DB value=mysql
key=java.vm.vendor value=Oracle Corporation
key=java.vendor.url value=http://java.oracle.com/
key=path.separator value=;
key=java.vm.name value=Java HotSpot(TM) 64-Bit Server VM
key=file.encoding.pkg value=sun.io
key=user.country value=CN
key=user.script value=
key=sun.java.launcher value=SUN_STANDARD
key=sun.os.patch.level value=
key=java.vm.specification.name value=Java Virtual Machine Specification
key=user.dir value=D:WorkSpaceEclipseWorkSpacespringboot_aop
key=java.runtime.version value=1.8.0_202-b08
key=java.awt.graphicsenv value=sun.awt.Win32GraphicsEnvironment
key=java.endorsed.dirs value=C:Program FilesJavajdk1.8.0_202jrelibendorsed
key=os.arch value=amd64
key=java.io.tmpdir value=C:UsersADMINI~1AppDataLocalTemp
key=line.separator value=
key=java.vm.specification.vendor value=Oracle Corporation
key=user.variant value=
key=os.name value=Windows 10
key=sun.jnu.encoding value=GBK
key=java.library.path value=C:Program FilesJavajdk1.8.0_202bin;C:WindowsSunJavabin;C:Windowssystem32;C:Windows;C:Program Files (x86)Common FilesOracleJavajavapath;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:WindowsSystem32OpenSSH;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program FilesNVIDIA CorporationNVIDIA NvDLISR;"C:Program FilesJavajdk1.8.0_202bin;C:Program FilesJavajdk1.8.0_202jrebin;";C:Program FilesGobin;C:Program FilesGobin;C:Program FilesPuTTY;C:Program FilesGitcmd;C:Program FilesTortoiseGitbin;C:Program FilesMicrosoft VS Codebin;C:UsersAdministratorAppDataLocalMicrosoftWindowsApps;C:UsersAdministratorgobin;C:Program FilesJetBrainsGoLand 2023.2bin;;C:Program FilesJetBrainsIntelliJ IDEA 2023.2.3bin;;.
key=java.specification.name value=Java Platform API Specification
key=java.class.version value=52.0
key=sun.management.compiler value=HotSpot 64-Bit Tiered Compilers
key=os.version value=10.0
key=user.home value=C:UsersAdministrator
key=user.timezone value=
key=java.awt.printerjob value=sun.awt.windows.WPrinterJob
key=file.encoding value=UTF-8
key=java.specification.version value=1.8
key=java.class.path value=C:Program FilesJavajdk1.8.0_202jrelibcharsets.jar;C:Program FilesJavajdk1.8.0_202jrelibdeploy.jar;C:Program FilesJavajdk1.8.0_202jrelibextaccess-bridge-64.jar;C:Program FilesJavajdk1.8.0_202jrelibextcldrdata.jar;C:Program FilesJavajdk1.8.0_202jrelibextdnsns.jar;C:Program FilesJavajdk1.8.0_202jrelibextjaccess.jar;C:Program FilesJavajdk1.8.0_202jrelibextjfxrt.jar;C:Program FilesJavajdk1.8.0_202jrelibextlocaledata.jar;C:Program FilesJavajdk1.8.0_202jrelibextnashorn.jar;C:Program FilesJavajdk1.8.0_202jrelibextsunec.jar;C:Program FilesJavajdk1.8.0_202jrelibextsunjce_provider.jar;C:Program FilesJavajdk1.8.0_202jrelibextsunmscapi.jar;C:Program FilesJavajdk1.8.0_202jrelibextsunpkcs11.jar;C:Program FilesJavajdk1.8.0_202jrelibextzipfs.jar;C:Program FilesJavajdk1.8.0_202jrelibjavaws.jar;C:Program FilesJavajdk1.8.0_202jrelibjce.jar;C:Program FilesJavajdk1.8.0_202jrelibjfr.jar;C:Program FilesJavajdk1.8.0_202jrelibjfxswt.jar;C:Program FilesJavajdk1.8.0_202jrelibjsse.jar;C:Program FilesJavajdk1.8.0_202jrelibmanagement-agent.jar;C:Program FilesJavajdk1.8.0_202jrelibplugin.jar;C:Program FilesJavajdk1.8.0_202jrelibresources.jar;C:Program FilesJavajdk1.8.0_202jrelibrt.jar;D:WorkSpaceEclipseWorkSpacespringboot_aoptargettest-classes;D:WorkSpaceEclipseWorkSpacespringboot_aoptargetclasses;D:.m2repoorgspringframeworkspring-context5.1.6.RELEASEspring-context-5.1.6.RELEASE.jar;D:.m2repoorgspringframeworkspring-aop5.1.6.RELEASEspring-aop-5.1.6.RELEASE.jar;D:.m2repoorgspringframeworkspring-beans5.1.6.RELEASEspring-beans-5.1.6.RELEASE.jar;D:.m2repoorgspringframeworkspring-core5.1.6.RELEASEspring-core-5.1.6.RELEASE.jar;D:.m2repoorgspringframeworkspring-jcl5.1.6.RELEASEspring-jcl-5.1.6.RELEASE.jar;D:.m2repoorgspringframe服务器托管网workspring-expression5.1.6.RELEASEspring-expression-5.1.6.RELEASE.jar;C:Program FilesJetBrainsIntelliJ IDEA 2023.2.3libidea_rt.jar
key=user.name value=Administrator
key=java.vm.specification.version value=1.8
key=sun.java.command value=com.lwz.TestSystemGetSet
key=java.home value=C:Program FilesJavajdk1.8.0_202jre
key=sun.arch.data.model value=64
key=user.language value=zh
key=java.specification.vendor value=Oracle Corporation
key=awt.toolkit value=sun.awt.windows.WToolkit
key=java.vm.info value=mixed mode
key=java.version value=1.8.0_202
key=java.ext.dirs value=C:Program FilesJavajdk1.8.0_202jrelibext;C:WindowsSunJavalibext
key=sun.boot.class.path value=C:Program FilesJavajdk1.8.0_202jrelibresources.jar;C:Program FilesJavajdk1.8.0_202jrelibrt.jar;C:Program FilesJavajdk1.8.0_202jrelibsunrsasign.jar;C:Program FilesJavajdk1.8.0_202jrelibjsse.jar;C:Program FilesJavajdk1.8.0_202jrelibjce.jar;C:Program FilesJavajdk1.8.0_202jrelibcharsets.jar;C:Program FilesJavajdk1.8.0_202jrelibjfr.jar;C:Program FilesJavajdk1.8.0_202jreclasses
key=java.vendor value=Oracle Corporation
key=file.separator value=
key=java.vendor.url.bug value=http://bugreport.sun.com/bugreport/
key=sun.io.unicode.encoding value=UnicodeLittle
key=sun.cpu.endian value=little
key=sun.desktop value=windows
key=sun.cpu.isalist value=amd64
一个程序员最重要的能力是:写出高质量的代码!!
有道无术,术尚可求也,有术无道,止于术。
无论你是年轻还是年长,所有程序员都需要记住:时刻努力学习新技术,否则就会被时代抛弃!
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
所有程序都共享CPU的有限资源,而由于某种原因的影响,系统应用程序就会变得缓慢或无响应,在这种情况下,我们就需要查看CPU使用率,并对其进行排查、处理,那么Linux中如何查看CPU使用率?在Linux中,可以通过以下方法查看CPU使用率。 1、服务器…