Get the OS : OS « Development Class « Java






Get the OS

     
/**
 *
    DEScribe - A Discrete Experience Sampling cross platform application
    Copyright (C) 2011
    Sbastien Faure <sebastien.faure3@gmail.com>,
    Bertrand Gros   <gros.bertrand@gmail.com>,
    Yannick Prie    <yannick.prie@univ-lyon1.fr>.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

//package api.utils;

/**
 * Class getOs.java
 * @description Tools around OS detection
 * @author Sbastien Faure  <sebastien.faure3@gmail.com>
 * @author Bertrand Gros    <gros.bertrand@gmail.com>
 * @version 2011-01-28
 */
public class getOs {

  public static boolean isWindows(){

    String os = System.getProperty("os.name").toLowerCase();
    //windows
      return (os.indexOf( "win" ) >= 0);

  }

  public static boolean isMac(){

    String os = System.getProperty("os.name").toLowerCase();
    //Mac
      return (os.indexOf( "mac" ) >= 0);

  }

  public static boolean isUnix(){

    String os = System.getProperty("os.name").toLowerCase();
    //linux or unix
      return (os.indexOf( "nix") >=0 || os.indexOf( "nux") >=0);

  }
}

   
    
    
    
    
  








Related examples in the same category

1.Class representing a standard operating system platform, WIN, MAC, or POSIX.
2.Get OS
3.Platform specific functionality.
4.Condition that tests the OS type.
5.Class to help determining the OS
6.Splits apart a OS separator delimited set of paths in a string into multiple Strings.
7.Get the operating systemGet the operating system
8.Virtual Machine Information (JVM)
9.Java Platform Information
10.Get OS Info
11.Platform Detector
12.OS detector
13.OS name
14.Operating System