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.mzph.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正常关闭虚拟机…