Java Get OS Name

This method returns the name of the operating system that the program is running in.

public static String getOsName() {
  String os = "";
  if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
    os = "windows";
  } else if (System.getProperty("os.name").toLowerCase().indexOf("linux") > -1) {
    os = "linux";
  } else if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) {
    os = "mac";
  }
 
  return os;
}

Donations appreciated. Every little $ helps. Or click Google +1

Related Posts with Thumbnails

tags: ,

4 Responses to “Java Get OS Name”

  1. 1
    Mike Thomson Says:

    Watch the latest episodes from your favourite tv-show and full, new movies for free! It’s right here: http://freefuntube.com

  2. 2
    movie streaming Says:

    I love this blog What a super blog!

  3. 3
    tech Says:

    @movie streaming: thank you

  4. 4
    latest tricks Says:

    Nice info, Thanks a lot for the info.

Leave a Reply

Spam protection by WP Captcha-Free