如何在Java 9中的JShell中获取Java和OS版本以及供应商详细信息?

Java 9引入了Java编程语言的JShell 工具。该工具使我们能够评估代码段,例如声明语句表达式。我们将获得有关细节Java版本供应商,并同时获得有关细节OS版本名称使用静态方法:的getProperty()系统级。

在下面的代码片段中,我们可以在JShell控制台中获取Java版本,Java供应商和OS版本以及OS名称的详细信息。

C:\Users\User>jshell
| Welcome to JShell -- Version 9.0.4
| For an introduction type: /help intro

jshell> System.out.println(System.getProperty("java.version"));
9.0.4

jshell> System.out.println(System.getProperty("java.vendor"));
Oracle Corporation

jshell> System.out.println(System.getProperty("os.version"));
6.3

jshell> System.out.println(System.getProperty("os.name"));
Windows 8.1

jshell>