我已阅读此,但是不够好!
我的意思是:我跑步时
java -version
java -version
我得到:
java version "1.8.0" Java(TM) SE Runtime Environment (build pxa6480sr3fp20-20161019_02(SR3 FP20)) IBM J9 VM (build 2.8, JRE 1.8.0 Linux amd64-64 Compressed References 20161013_322271 (JIT enabled, AOT enabled) J9VM - R28_Java8_SR3_20161013_1635_B322271 JIT - tr.r14.java.green_20161011_125790 GC - R28_Java8_SR3_20161013_1635_B322271_CMPRSS...
但是,当我使用任何编程方式从内部"访问JVM版本时(如我所链接的问题所概述),我只会看到诸如以下的值:
But when I use any of the programmatic ways to access the JVM version "from within" (as outlined by the question I am linking to), I only see values such as:
Property: java.vm.specification.version : 1.8 Property: java.vm.specification.vendor : Oracle Corporation Property: java.vm.specification.name : Java Virtual Machine Specification Property: java.vm.version : 2.8 Property: java.vm.vendor : IBM Corporation Property: java.vm.name : IBM J9 VM Property: java.specification.version : 1.8 Property: java.specification.vendor : Oracle Corporation Property: java.specification.name : Java Platform API Specification使用
MX bean --- vmversion: 2.8我的问题:我们的构建服务器运行的是IBM Java的旧版本. java -version会显示出类似
My problem: our build server runs a slightly older version of IBM java. java -version would show that, like
J9VM - R28_Java8_SR1_20150410_1531_B243669但是:当我打印这些系统属性时,这些详细信息会丢失!我还没有找到一种写Java代码的方法,该方法可以区分稍旧的JVM和较新的JVM.
But: when I print those system properties, such details are lost! I have not found a way to write java code that would be able to distinguish that slightly older JVM from the newer one.
长话短说:在我的JVM中"是否有任何编程方式可以使我获得如此详细的信息?
Long story short: is there any programmatic way to do something "within my JVM" that would give me that level of detail?
(基本上,我需要使用它来动态禁用某些JUnit测试;它们根本无法与较早的JVM一起使用;但是我希望在使用较新的JVM在我的本地Eclipse安装中运行时执行它们)
(basically I need that to dynamically disable some of our JUnit tests; they simply dont work with the older JVM; but I want them to be executed when running in my local eclipse installation with a newer JVM)
推荐答案我没有IBM Java,只有Oracle Java.当我执行java -version时,我得到:
I don't have IBM Java, only Oracle Java. When I do java -version I get:
java version "1.8.0_91" Java(TM) SE Runtime Environment (build 1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)我可以使用以下代码重现该确切的输出:
I can reproduce that exact output with this code:
System.out.printf("java version \"%s\"%n" + "%s (build %s)%n" + "%s (build %s, %s)%n", System.getProperty("java.version"), System.getProperty("java.runtime.name"), System.getProperty("java.runtime.version"), System.getProperty("java.vm.name"), System.getProperty("java.vm.version"), System.getProperty("java.vm.info"));IBM Java可能还添加了其他信息.为什么不尝试转储所有系统属性并亲自查看:
There might be other information added by IBM Java. Why not try dumping all system properties and see for yourself:
new TreeMap<>(System.getProperties()).entrySet().forEach(e -> System.out.printf("%s = %s%n", e.getKey(), e.getValue()) );更多推荐
如何从程序中找到JVM版本……甚至还有更多详细信息?
发布评论