检测Windows还是Linux? [英] Detecting Windows or Linux?
本文介绍了检测Windows还是Linux?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻求在Windows和Linux中运行一个通用的Java程序。
I am seeking to run a common Java program in both Windows and Linux.
程序需要在每个平台上做一些不同的事情。
The program needs to do some things differently on each platform.
那么我的Java程序如何检测它是否应该在Linux vs. Windows下运行?
So how can / should my Java program detect it is running under Linux vs. Windows?
推荐答案
apache commons lang 有一个类 SystemUtils.java
you可以使用:
apache commons lang has a class SystemUtils.java you can use :
SystemUtils.IS_OS_LINUX
SystemUtils.IS_OS_WINDOWS
这篇关于检测Windows还是Linux?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文