Java Tools Class (gets the current host operating system Name)

Source: Internet
Author: User

 packagecom.fly.jenkins.util;/*** Operating system class: get System.getproperty ("os.name") corresponding to the operating system * *@authorisea533*/ public classOSinfo {Private StaticString OS = System.getproperty ("os.name"). toLowerCase (); Private StaticOSinfo _instance =NewOSinfo (); PrivateEplatform platform; PrivateOSinfo () {} public Static Booleanislinux () {returnOs.indexof ("linux") >= 0; }     public Static BooleanIsmacos () {returnOs.indexof ("mac") >= 0 && os.indexof ("OS") > 0 && os.indexof ("x") < 0; }     public Static Booleanismacosx () {returnOs.indexof ("mac") >= 0 && os.indexof ("OS") > 0 && os.indexof ("x") > 0; }     public Static Booleaniswindows () {returnOs.indexof ("windows") >= 0; }     public Static BooleanisOS2 () {returnOs.indexof ("os/2") >= 0; }     public Static BooleanIssolaris () {returnOs.indexof ("solaris") >= 0; }     public Static BooleanIssunos () {returnOs.indexof ("sunos") >= 0; }     public Static BooleanIsmpeix () {returnOs.indexof ("mpe/ix") >= 0; }     public Static Booleanishpux () {returnOs.indexof ("hp-ux") >= 0; }     public Static BooleanIsaix () {returnOs.indexof ("aix") >= 0; }     public Static BooleanisOS390 () {returnOs.indexof ("os/390") >= 0; }     public Static BooleanIsfreebsd () {returnOs.indexof ("freebsd") >= 0; }     public Static BooleanIsirix () {returnOs.indexof ("irix") >= 0; }     public Static BooleanIsdigitalunix () {returnOs.indexof ("digital") >= 0 && os.indexof ("unix") > 0; }     public Static Booleanisnetware () {returnOs.indexof ("netware") >= 0; }     public Static BooleanisOSF1 () {returnOs.indexof ("osf1") >= 0; }     public Static BooleanIsopenvms () {returnOs.indexof ("openvms") >= 0; }    /*** Get Operating system name * *@returnOperating system name*/     public Staticeplatform getosname () {if(isaix ()) {_instance.platform=eplatform.aix; } Else if(isdigitalunix ()) {_instance.platform=eplatform.digital_unix; } Else if(isfreebsd ()) {_instance.platform=eplatform.freebsd; } Else if(ishpux ()) {_instance.platform=eplatform.hp_ux; } Else if(isirix ()) {_instance.platform=eplatform.irix; } Else if(islinux ()) {_instance.platform=eplatform.linux; } Else if(ismacos ()) {_instance.platform=eplatform.mac_os; } Else if(ismacosx ()) {_instance.platform=eplatform.mac_os_x; } Else if(ismpeix ()) {_instance.platform=eplatform.mpeix; } Else if(isnetware ()) {_instance.platform=eplatform.netware_411; } Else if(isopenvms ()) {_instance.platform=eplatform.openvms; } Else if(isOS2 ()) {_instance.platform=eplatform.os2; } Else if(isOS390 ()) {_instance.platform=eplatform.os390; } Else if(isOSF1 ()) {_instance.platform=eplatform.osf1; } Else if(issolaris ()) {_instance.platform=eplatform.solaris; } Else if(issunos ()) {_instance.platform=eplatform.sunos; } Else if(iswindows ()) {_instance.platform=eplatform.windows; } Else{_instance.platform=eplatform.others; }        return_instance.platform; }    /**     * @paramargs*/     public Static voidmain (string[] Args) {System.out.println (osinfo.getosname ()); }    /*** Platform * *@authorisea533*/     public enumeplatform {any ("any"), linux ("linux"), mac_os ("mac os"), mac_os_x ("mac os X"), windows ("windows"), OS2 ("os/2"), Solaris ("Solaris"), SunOS ("SunOS"), Mpeix ("mpe/ix"), hp_ux ("hp-ux"), Aix ("aix"), OS390 ("os/390"), FreeBSD ("FreeBSD"), Irix ("Irix"), Digital_unix ("Digital Unix"), netware_411 ("NetWare"), OSF1 ("OSF1"), OpenVMS ("OpenVMS"), Others ("Others")); Privateeplatform (String Desc) { this. Description =desc; }         publicString toString () {returndescription; }        PrivateString description; }}

Java Tools Class (gets the current host operating system Name)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.