首页 > 文章列表 > 在Java 9中如何在JShell中获取Java和操作系统版本以及供应商详细信息?

在Java 9中如何在JShell中获取Java和操作系统版本以及供应商详细信息?

208 2023-08-28

Java 9 引入了 Java 编程语言的 JShell 工具。该工具允许我们评估代码片段,例如声明语句表达式。我们将获取有关Java版本供应商的详细信息,并获取有关操作系统版本名称的详细信息使用静态方法:System 类的getProperty()

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

C:UsersUser>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>