modules/jdk.packager/src/main/java/com/oracle/tools/packager/Platform.java

Print this page




  59         if (os.indexOf("win") >= 0) {
  60             platform = Platform.WINDOWS;
  61         }
  62         else if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0) {
  63             platform = Platform.LINUX;
  64         }
  65         else if (os.indexOf("mac") >= 0) {
  66             platform = Platform.MAC;
  67         }
  68         else {
  69             platform = Platform.UNKNOWN;
  70         }
  71 
  72         String version = System.getProperty("os.version").toString();
  73         String[] parts = version.split(Pattern.quote("."));
  74 
  75         if (parts.length > 0) {
  76             majorVersion = Integer.parseInt(parts[0]);
  77 
  78             if (parts.length > 1) {
  79                 minorVersion = Integer.parseInt(parts[0]);
  80             }
  81             else {
  82                 minorVersion = -1;
  83             }
  84         }
  85         else {
  86             majorVersion = -1;
  87             minorVersion = -1;
  88         }
  89     }
  90 
  91     private Platform() {}
  92 
  93     public static Platform getPlatform() {
  94         return platform;
  95     }
  96 
  97     public static int getMajorVersion() {
  98         return majorVersion;
  99     }


  59         if (os.indexOf("win") >= 0) {
  60             platform = Platform.WINDOWS;
  61         }
  62         else if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0) {
  63             platform = Platform.LINUX;
  64         }
  65         else if (os.indexOf("mac") >= 0) {
  66             platform = Platform.MAC;
  67         }
  68         else {
  69             platform = Platform.UNKNOWN;
  70         }
  71 
  72         String version = System.getProperty("os.version").toString();
  73         String[] parts = version.split(Pattern.quote("."));
  74 
  75         if (parts.length > 0) {
  76             majorVersion = Integer.parseInt(parts[0]);
  77 
  78             if (parts.length > 1) {
  79                 minorVersion = Integer.parseInt(parts[1]);
  80             }
  81             else {
  82                 minorVersion = -1;
  83             }
  84         }
  85         else {
  86             majorVersion = -1;
  87             minorVersion = -1;
  88         }
  89     }
  90 
  91     private Platform() {}
  92 
  93     public static Platform getPlatform() {
  94         return platform;
  95     }
  96 
  97     public static int getMajorVersion() {
  98         return majorVersion;
  99     }