java-System

public class SystemDemo {
  public static void main(String[] args) {
    /*
      os.name	操作系统的名称
      os.arch	操作系统的架构
      os.version	操作系统的版本
      file.separator	文件分隔符(在 UNIX 系统中是“/”)
      path.separator	路径分隔符(在 UNIX 系统中是“:”)
      line.separator	行分隔符(在 UNIX 系统中是“/n”)
      user.name	用户的账户名称
      user.home	用户的主目录
      user.dir	用户的当前工作目录
      java.class.version	Java 类格式版本号
      java.class.path	Java 类路径
      java.vm.version	Java 虚拟机实现版本
    */
    System.out.println("os.name:" + System.getProperty("os.name"));
    System.out.println("os.arch:" + System.getProperty("os.arch"));
    System.out.println("os.version:" + System.getProperty("os.version"));
    System.out.println("file.separator:" + System.getProperty("file.separator"));
    System.out.println("path.separator:" + System.getProperty("path.separator"));
    System.out.println("user.name:" + System.getProperty("user.name"));
    System.out.println("user.home:" + System.getProperty("user.home"));
    System.out.println("user.dir:" + System.getProperty("user.dir"));
    System.out.println("java.class.version:" + System.getProperty("java.class.version"));
    System.out.println("java.class.path:" + System.getProperty("java.class.path"));
    System.out.println("java.vm.version:" + System.getProperty("java.vm.version"));
	getSystemProperties();
  }
  /**
  * 获取所有的系统变量
  */
  public static void getSystemProperties() {
        Properties properties = System.getProperties();
        properties.list(System.out);
    }
}

os.name:Windows 11
os.arch:amd64
os.version:10.0
file.separator:\
path.separator:;
user.name:Administrator
user.home:C:\Users\Administrator
user.dir:D:\java\project\j2se
java.class.version:61.0
java.class.path:D:\java\project\j2se\day02\target\classes;D:\Program Files\JetBrains\IntelliJ IDEA 2022.1.3\plugins\maven\lib\maven3\mysql\mysql-connector-java\8.0.28\mysql-connector-java-8.0.28.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2022.1.3\plugins\maven\lib\maven3\com\google\protobuf\protobuf-java\3.11.4\protobuf-java-3.11.4.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2022.1.3\plugins\maven\lib\maven3\cn\hutool\hutool-all\5.8.12\hutool-all-5.8.12.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2022.1.3\plugins\maven\lib\maven3\org\projectlombok\lombok\1.18.24\lombok-1.18.24.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2022.1.3\plugins\maven\lib\maven3\com\belerweb\pinyin4j\2.5.0\pinyin4j-2.5.0.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2022.1.3\plugins\maven\lib\maven3\io\github\biezhi\TinyPinyin\2.0.3.RELEASE\TinyPinyin-2.0.3.RELEASE.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2022.1.3\plugins\maven\lib\maven3\org\ahocorasick\ahocorasick\0.4.0\ahocorasick-0.4.0.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2022.1.3\plugins\maven\lib\maven3\com\github\stuxuhai\jpinyin\1.1.8\jpinyin-1.1.8.jar;D:\java\project\j2se\lib\druid-1.2.8.jar
java.vm.version:17.0.6+9-LTS-190

-- listing properties --
java.specification.version=17
sun.cpu.isalist=amd64
sun.jnu.encoding=GBK
java.class.path=E:\java\project\autobean\target\class...
java.vm.vendor=Oracle Corporation
sun.arch.data.model=64
user.variant=
java.vendor.url=https://java.oracle.com/
user.timezone=Asia/Shanghai
java.vm.specification.version=17
os.name=Windows 11
sun.java.launcher=SUN_STANDARD
user.country=CN
sun.boot.library.path=E:\soft\java\jdk17.0.6\bin
spring.application.admin.enabled=true
sun.java.command=cn.tjhis.AutobeanApplication
com.sun.management.jmxremote=
jdk.debug=release
spring.liveBeansView.mbeanDomain=
sun.cpu.endian=little
user.home=C:\Users\Administrator
user.language=zh
java.specification.vendor=Oracle Corporation
java.version.date=2023-01-17
java.home=E:\soft\java\jdk17.0.6
spring.output.ansi.enabled=always
file.separator=\
java.vm.compressedOopsMode=Zero based
line.separator=

java.vm.specification.vendor=Oracle Corporation
java.specification.name=Java Platform API Specification
FILE_LOG_CHARSET=UTF-8
java.awt.headless=true
user.script=
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
java.runtime.version=17.0.6+9-LTS-190
user.name=Administrator
spring.jmx.enabled=true
path.separator=;
os.version=10.0
java.runtime.name=Java(TM) SE Runtime Environment
file.encoding=UTF-8
spring.beaninfo.ignore=true
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.vendor.url.bug=https://bugreport.java.com/bugreport/
java.io.tmpdir=C:\Users\ADMINI~1\AppData\Local\Temp\
java.version=17.0.6
user.dir=E:\java\project\autobean
os.arch=amd64
java.vm.specification.name=Java Virtual Machine Specification
PID=14188
sun.os.patch.level=
CONSOLE_LOG_CHARSET=UTF-8
native.encoding=GBK
java.library.path=E:\soft\java\jdk17.0.6\bin;C:\WINDOWS...
java.vm.info=mixed mode, emulated-client, sharing
java.vendor=Oracle Corporation
java.vm.version=17.0.6+9-LTS-190
java.rmi.server.randomIDs=true
sun.io.unicode.encoding=UnicodeLittle
java.class.version=61.0

posted @ 2023-02-28 17:51  his365  阅读(32)  评论(0编辑  收藏  举报