Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35627

Re: Possible operating system names?

Newsgroups comp.lang.java.programmer
Date 2016-09-21 11:44 -0700
References <6f333feb-83a0-4165-8c9e-65757564d6c2@googlegroups.com>
Message-ID <83077510-127c-47fc-93af-8a4199167c00@googlegroups.com> (permalink)
Subject Re: Possible operating system names?
From mcheung63@gmail.com

Show all headers | View raw


Oliver Ruebenacker於 2016年9月21日星期三 UTC+8下午11時27分28秒寫道:
> Hello,
> 
>   Where can I get list of all common operating system names (i.e. the most common values for System.getProperty("os.name"))?
> 
>   Thanks!
> 
>      Best, Oliver
> 
> -- 
> Oliver Ruebenacker
> Senior Software Engineer, Diabetes Portal, Broad Institute

Hope this help

package com.mkyong.core;

public class OSValidator {

	private static String OS = System.getProperty("os.name").toLowerCase();

	public static void main(String[] args) {

		System.out.println(OS);

		if (isWindows()) {
			System.out.println("This is Windows");
		} else if (isMac()) {
			System.out.println("This is Mac");
		} else if (isUnix()) {
			System.out.println("This is Unix or Linux");
		} else if (isSolaris()) {
			System.out.println("This is Solaris");
		} else {
			System.out.println("Your OS is not support!!");
		}
	}

	public static boolean isWindows() {

		return (OS.indexOf("win") >= 0);

	}

	public static boolean isMac() {

		return (OS.indexOf("mac") >= 0);

	}

	public static boolean isUnix() {

		return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 );

	}

	public static boolean isSolaris() {

		return (OS.indexOf("sunos") >= 0);

	}

}

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Possible operating system names? Oliver Ruebenacker <curoli@gmail.com> - 2016-09-21 08:25 -0700
  Re: Possible operating system names? mcheung63@gmail.com - 2016-09-21 11:44 -0700
    Re: Possible operating system names? Graeme Geldenhuys <graemeg@example.net> - 2016-09-22 11:29 +0100
      Re: Possible operating system names? Arne Vajhøj <arne@vajhoej.dk> - 2016-09-22 19:24 -0400
  Re: Possible operating system names? Daniel Pitts <usenet@coloraura.com> - 2016-09-25 09:01 -0700

csiph-web