
Java 9 引入了 Java 编程语言的 JShell 工具。该工具允许我们评估代码片段,例如声明、语句和表达式。我们将获取有关Java版本和供应商的详细信息,并获取有关操作系统版本和名称的详细信息使用静态方法:System 类的getProperty()。
在下面的代码片段中,我们可以获取详细信息JShell 控制台中的 Java 版本、Java 供应商和操作系统版本以及操作系统名称。
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>











