java 系統自動檢測_如何在Java中檢測OS(操作系統)名稱?

java 系統自動檢測

To detect the OS (operating system) name in Java, we use the getProperties() method, which is defined in System class, while calling the method, we need to pass the property name to get the OS (operating system name).

檢測Java中的OS(操作系統)名稱 ,我們使用System類中定義的getProperties()方法 ,在調用該方法時,我們需要傳遞屬性名稱以獲取OS(操作系統名稱)。

The property to get the OS name is: "os.name"

獲取操作系統名稱的屬性是: “ os.name”

The method call is: System.getProperties("os.name");

方法調用為: System.getProperties(“ os.name”);

Java code to detect and print the OS (operating system) name

用于檢測和打印OS(操作系統)名稱的Java代碼

// Java program to demonstrate the example of 
// getProperties() method of System Class
import java.lang.*;
import java.util.Properties;
public class Main {
public static void main(String[] args) {
String os_name = null;
os_name = System.getProperty("os.name");
System.out.println("OS name is: " + os_name);
}
}

Output

輸出量

OS name is: Linux

翻譯自: https://www.includehelp.com/java/how-to-detect-the-os-operating-system-name-in-java.aspx

java 系統自動檢測

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/542208.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542208.shtml
英文地址,請注明出處:http://en.pswp.cn/news/542208.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

shell中返回值是1為真還是假_shell腳本中判斷上一個命令是否執行成功

SQL Server 系列文章快速導航(SWF版)一.前言 在博客園寫博客不自不覺已經有5個年頭了,一開始只是為了記錄工作中遇到的問題和解決辦法,后來寫的文章不自不覺的側重在SQL Server方面的技術文章,在2014年1月終于鼓起勇氣申請了微軟S ...duilib幫助1.窗口基類:見介紹 順便貼下出來…

Linux中對進程的管理

1.what is 進程 程序(program)放置在儲存媒體中(如硬盤、光盤、軟盤、磁盤等),為實體的型態存在。 進程:程序被觸發后,執行者的權限與屬性、程序的程序碼與所需數據等都會被載入內存中&#xff…

帶C#示例的String.Equality(==)運算符

C#String.Equality運算符 (C# String.Equality operator ) "" is a String.Equality operator in C#, it is used to check whether two strings objects have the same values or not. “ ”是C#中的String.Equality運算符 ,用于檢…

jQuery 倒計時

function getSec(){//獲取名稱為remindataSec的ulobj document.getElementsByName("remindataSec");for(i0;i<obj.length;i){//循環得到每個毫秒數var intDiff $("#remindataTime"i"").text();var id "reminTime"i;//得到毫秒數…

Linux遠程連接與sshd服務安全設定

1.遠程連接&#xff1a; 首先設置ip&#xff1a; 設置好之后&#xff0c;先ping一下IP 看能不能通 ssh root172.25.13.103 ##表示的是&#xff1a;連接ip為172.25.13.103的root用戶 2.系統控制命令 系統控制命令的查看相關參數如下表 systemctl服務控制命令systemctl stat…

rabbitmq 同步策略_RabbitMQ高可用方案總結

RabbitMQ的集群方案有以下幾種&#xff1a;1.普通的集群exchange&#xff0c;buindling再所有的節點上都會保存一份&#xff0c;但是queue只會存儲在其中的一個節點上&#xff0c;但是所有的節點都會存儲一份queue的meta信息。因為這樣有兩個好處&#xff1a;1)存儲空間。如果每…

一個簡單的封ip規則

2019獨角獸企業重金招聘Python工程師標準>>> 一個簡單通過nginx日志封ip規則&#xff08;僅僅自己方便使用&#xff09; #!/bin/bash #Version:1.0 #Date:2016-08-09 #作用:防刷IP地址,解封蜘蛛,解封5天前封的IP地址function deny () { Date$(date "%F-%H-%M&q…

c程序預處理器的設計與實現_C預處理器-能力問題與解答

c程序預處理器的設計與實現C programming Pre-processor Aptitude Questions and Answers: In this section you will find C Aptitude Questions and Answers on Pre-processor topics like #define, #undef, #if, #endif etc. C編程預處理程序能力問題和解答&#xff1a;在本…

系統日志管理

1 查看系統中的日志 rsyslog 此服務是用來采集系統日志的&#xff0c;他不產生日志&#xff0c;只是起到采集作用 2 rsyslog 的管理 /var/log/messages服務信息日志/var/log/secuer系統登陸日志/var/log/cron定時任務日志/var/log/maillog郵件日志/var/log/boot.log系統啟動日…

pythonassertbug_還在 Bug 不斷?不妨試試這 2 個裝X技巧

原標題&#xff1a;還在 Bug 不斷&#xff1f;不妨試試這 2 個裝X技巧作者 | luanhz來源 | 小數志(ID&#xff1a;Datazhi)程序員每天遇到 bug 就像喝水吃飯一樣稀松平常&#xff0c;關鍵在于怎么高效而不失優雅的面對這些 bug&#xff01;所以&#xff0c;你還在固執的使用 tr…

iOS10 UI教程視圖的邊界與視圖的框架

2019獨角獸企業重金招聘Python工程師標準>>> iOS10 UI教程視圖的邊界與視圖的框架 iOS10 UI視圖的邊界 在視圖的幾何形狀中我們提到了視圖屬性中的一部分屬性可以將定義的視圖繪制在屏幕上。其中典型的3個屬性為邊界屬性、框架屬性以及中心位置屬性。 bounds表示的就…

Java System類runFinalization()方法及示例

系統類runFinalization()方法 (System class runFinalization() method) runFinalization() method is available in java.lang package. runFinalization()方法在java.lang包中可用。 runFinalization() method is used to run the finalize() methods of any object that are…

Linux中遠程文件的傳輸

1. scp命令 scp file userip:/dir 把自己主機的文件遠程復制到其他主機 scp userip:/file dir 把其他主機的文件遠程復制到當前主機 注意&#xff1a;要關閉接受端的防火墻 把主機的file遠程復制到IP為172.25.254.117的root用戶的Desktop 把IP為172.25.254.117的root用戶Deskt…

svn: Can't convert string from 'UTF-8' to native

詳見&#xff1a;http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt227 svn 版本庫中有文件是以中文字符命名的&#xff0c;在 Linux 下 checkout 會報錯&#xff1a; svn: Cant convert string from UTF-8 to native encoding 然后 checkout 程序就退出了&#xff…

引入antd組件樣式_個人作品:一個技術棧koa2+ mysql+react + antd的個人博客

前言此項目是個人博客&#xff0c;有前端界面后臺管理系統&#xff1b;目的是當做react和node的練手項目&#xff0c;同時還可以了解到服務器nginx部署web站點以及備案和域名的基本操作流程。項目預覽地址https://www.lxsblog.cn?www.lxsblog.cnGitHub地址LinWeb/blog?github…

Java ObjectOutputStream writeLong()方法與示例

ObjectOutputStream類writeLong()方法 (ObjectOutputStream Class writeLong() method) writeLong() method is available in java.io package. writeLong()方法在java.io包中可用。 writeLong() method is used to write the given 8 bytes long value. writeLong()方法用于寫…

淺談Jfinal急速開發框架

2019獨角獸企業重金招聘Python工程師標準>>> 使用Jfinal一段時間了,記得當初14年吧,為了建立一個簡單的門戶網站,想找個輕量型的急速開發框架,然后搜到Jfinal,然后用了一段時間后,確實不錯, 現在吧,隨著時間的推移,作者對JFinal的版本迭代也是一直在努力,一直朝著優…

make 怎么降級_Ubuntu 中將 make 的版本降低

最新的 Ubuntu 版本使用的是 make 版本是 4.0.在編譯 Android4.4 源碼包時&#xff0c;由于 make 版本過高&#xff0c;命令提示行會提示編譯 Android4.4 源碼包需要 make 的版本為 3.81 或 3.82.build/core/main.mk:42: ****************************************************…

Java ObjectOutputStream writeChar()方法與示例

ObjectOutputStream類writeChar()方法 (ObjectOutputStream Class writeChar() method) writeChar() method is available in java.io package. writeChar()方法在java.io包中可用。 writeChar() method is used to write 2 bytes of a character value. writeChar()方法用于寫…

虛擬機的管理

我們采用虛擬機的原因是什么呢&#xff0c;很簡單就倆字&#xff1a; 節能 1. 管理虛擬機的命令&#xff1a; virt-manager開啟虛擬機管理器virsh list顯示正在運行的虛擬機virsh list --all查看所有虛擬機virsh start desktop打開虛擬機virsh shutdown desktop正常關閉虛擬機…