今天用到了,System.getProperty(“user.dir”);想看一下都有哪些系统属性,如是有了下面的测试代码。
class Test {
public static void main(String[] args) {
Properties properties = System.getProperties();
for (String key : properties.stringPropertyNames()) {
System.out.println(key + "=" + properties.getProperty(key));
}
Scanner scanner = new Scanner(System.in);
String next = scanner.next();
}
}
输出结果有这些:
gopherProxySet=false
awt.toolkit=sun.lwawt.macosx.LWCToolkit
java.specification.version=11
sun.cpu.isalist=
sun.jnu.encoding=UTF-8
java.class.path=/Users/huang/IdeaProjects/nettylearn/target/classes:/Users/huang/repository/io/netty/netty-all/5.0.0.Alpha1/netty-all-5.0.0.Alpha1.jar:/Users/huang/repository/org/msgpack/msgpack/0.6.6/msgpack-0.6.6.jar:/Users/huang/repository/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar:/Users/huang/repository/junit/junit/4.10/junit-4.10.jar:/Users/huang/repository/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar:/Users/huang/repository/org/javassist/javassist/3.16.1-GA/javassist-3.16.1-GA.jar:/Users/huang/repository/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA.jar:/Users/huang/repository/com/google/protobuf/protobuf-java/3.10.0/protobuf-java-3.10.0.jar
java.vm.vendor=Oracle Corporation
sun.arch.data.model=64
java.vendor.url=http://java.oracle.com/
user.timezone=
os.name=Mac OS X
java.vm.specification.version=11
sun.java.launcher=SUN_STANDARD
user.country=CN
sun.boot.library.path=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/lib
sun.java.command=_10.Test
jdk.debug=release
sun.cpu.endian=little
user.home=/Users/huang
user.language=zh
java.specification.vendor=Oracle Corporation
java.version.date=2018-09-25
java.home=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
file.separator=/
java.vm.compressedOopsMode=Zero based
line.separator=
java.specification.name=Java Platform API Specification
java.vm.specification.vendor=Oracle Corporation
java.awt.graphicsenv=sun.awt.CGraphicsEnvironment
user.script=Hans
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
java.runtime.version=11+28
user.name=huang
path.separator=:
os.version=10.15
java.runtime.name=Java(TM) SE Runtime Environment
file.encoding=UTF-8
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.vendor.version=18.9
java.vendor.url.bug=http://bugreport.java.com/bugreport/
java.io.tmpdir=/var/folders/hx/ybjkn_sd0hv73sjl_6_dsfjr0000gn/T/
java.version=11
user.dir=/Users/huang/IdeaProjects/nettylearn
os.arch=x86_64
java.vm.specification.name=Java Virtual Machine Specification
java.awt.printerjob=sun.lwawt.macosx.CPrinterJob
sun.os.patch.level=unknown
java.library.path=/Users/huang/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
java.vendor=Oracle Corporation
java.vm.info=mixed mode
java.vm.version=11+28
sun.io.unicode.encoding=UnicodeBig
java.class.version=55.0
Process finished with exit code 137 (interrupted by signal 9: SIGKILL)
这时我想起了jinfo工具,用来查看虚拟机参数的。
首先使用,查询目标的pid,我们查到24294
jps -l
再使用jinfo 命令查看(pid要换成刚才查到的pid)
info -sysprops 24294
呵呵,然后就悲剧了。
百度一波。。发现有的博客说是jdk 的 bug,换成jdk11试试,然后。。。同样的问题,并没有解决。系统有解决的分享一下经验。