如何在 Java 9 中透過 JShell 獲取 Java 和作業系統版本以及供應商詳細資訊?
Java 9 為 Java 程式語言引入了JShell 工具。此工具允許我們計算程式碼片段,例如宣告、語句和表示式。我們可以透過使用 System 類的靜態方法getProperty()獲得 Java 版本和供應商的詳細資訊以及 OS 版本和名稱的詳細資訊。
在下方的程式碼片段中,我們能夠在 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>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP