SystemUtils.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      https://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.apache.commons.lang3;

  18. import java.io.File;
  19. import java.nio.file.Path;
  20. import java.nio.file.Paths;

  21. /**
  22.  * Helpers for {@link System}.
  23.  *
  24.  * <p>
  25.  * If a system property cannot be read due to security restrictions, the corresponding field in this class will be set to {@code null} and a message will be
  26.  * written to {@code System.err}.
  27.  * </p>
  28.  * <p>
  29.  * #ThreadSafe#
  30.  * </p>
  31.  *
  32.  * @since 1.0
  33.  * @see SystemProperties
  34.  */
  35. public class SystemUtils {

  36.     /**
  37.      * The prefix String for all Windows OS.
  38.      */
  39.     private static final String OS_NAME_WINDOWS_PREFIX = "Windows";

  40.     // System property constants
  41.     // -----------------------------------------------------------------------
  42.     // These MUST be declared first. Other constants depend on this.

  43.     /**
  44.      * A constant for the System Property {@code file.encoding}.
  45.      *
  46.      * <p>
  47.      * File encoding, such as {@code Cp1252}.
  48.      * </p>
  49.      * <p>
  50.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  51.      * </p>
  52.      * <p>
  53.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  54.      * called after this class is loaded, the value will be out of sync with that System property.
  55.      * </p>
  56.      *
  57.      * @see SystemProperties#getFileEncoding()
  58.      * @since 2.0
  59.      * @since Java 1.2
  60.      */
  61.     public static final String FILE_ENCODING = SystemProperties.getFileEncoding();

  62.     /**
  63.      * A constant for the System Property {@code file.separator}.
  64.      * <p>
  65.      * The file separator is:
  66.      * </p>
  67.      * <ul>
  68.      * <li>{@code "/"} on Unix</li>
  69.      * <li>{@code "\"} on Windows.</li>
  70.      * </ul>
  71.      *
  72.      * <p>
  73.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  74.      * </p>
  75.      * <p>
  76.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  77.      * called after this class is loaded, the value will be out of sync with that System property.
  78.      * </p>
  79.      *
  80.      * @see SystemProperties#getFileSeparator()
  81.      * @deprecated Use {@link File#separator}, since it is guaranteed to be a string containing a single character and it does not require a privilege check.
  82.      * @since Java 1.1
  83.      */
  84.     @Deprecated
  85.     public static final String FILE_SEPARATOR = SystemProperties.getFileSeparator();

  86.     /**
  87.      * A constant for the System Property {@code java.awt.fonts}.
  88.      *
  89.      * <p>
  90.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  91.      * </p>
  92.      * <p>
  93.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  94.      * called after this class is loaded, the value will be out of sync with that System property.
  95.      * </p>
  96.      *
  97.      * @see SystemProperties#getJavaAwtFonts()
  98.      * @since 2.1
  99.      */
  100.     public static final String JAVA_AWT_FONTS = SystemProperties.getJavaAwtFonts();

  101.     /**
  102.      * A constant for the System Property {@code java.awt.graphicsenv}.
  103.      *
  104.      * <p>
  105.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  106.      * </p>
  107.      * <p>
  108.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  109.      * called after this class is loaded, the value will be out of sync with that System property.
  110.      * </p>
  111.      *
  112.      * @see SystemProperties#getJavaAwtGraphicsenv()
  113.      * @since 2.1
  114.      */
  115.     public static final String JAVA_AWT_GRAPHICSENV = SystemProperties.getJavaAwtGraphicsenv();

  116.     /**
  117.      * A constant for the System Property {@code java.awt.headless}. The value of this property is the String {@code "true"} or {@code "false"}.
  118.      *
  119.      * <p>
  120.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  121.      * </p>
  122.      * <p>
  123.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  124.      * called after this class is loaded, the value will be out of sync with that System property.
  125.      * </p>
  126.      *
  127.      * @see #isJavaAwtHeadless()
  128.      * @see SystemProperties#getJavaAwtHeadless()
  129.      * @since 2.1
  130.      * @since Java 1.4
  131.      */
  132.     public static final String JAVA_AWT_HEADLESS = SystemProperties.getJavaAwtHeadless();

  133.     /**
  134.      * A constant for the System Property {@code java.awt.printerjob}.
  135.      *
  136.      * <p>
  137.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  138.      * </p>
  139.      * <p>
  140.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  141.      * called after this class is loaded, the value will be out of sync with that System property.
  142.      * </p>
  143.      *
  144.      * @see SystemProperties#getJavaAwtPrinterjob()
  145.      * @since 2.1
  146.      */
  147.     public static final String JAVA_AWT_PRINTERJOB = SystemProperties.getJavaAwtPrinterjob();

  148.     /**
  149.      * A constant for the System Property {@code java.class.path}. Java class path.
  150.      *
  151.      * <p>
  152.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  153.      * </p>
  154.      * <p>
  155.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  156.      * called after this class is loaded, the value will be out of sync with that System property.
  157.      * </p>
  158.      *
  159.      * @see SystemProperties#getJavaClassPath()
  160.      * @since Java 1.1
  161.      */
  162.     public static final String JAVA_CLASS_PATH = SystemProperties.getJavaClassPath();

  163.     /**
  164.      * A constant for the System Property {@code java.class.version}. Java class format version number.
  165.      *
  166.      * <p>
  167.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  168.      * </p>
  169.      * <p>
  170.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  171.      * called after this class is loaded, the value will be out of sync with that System property.
  172.      * </p>
  173.      *
  174.      * @see SystemProperties#getJavaClassVersion()
  175.      * @since Java 1.1
  176.      */
  177.     public static final String JAVA_CLASS_VERSION = SystemProperties.getJavaClassVersion();

  178.     /**
  179.      * A constant for the System Property {@code java.compiler}. Name of JIT compiler to use. First in JDK version 1.2. Not used in Sun JDKs after 1.2.
  180.      *
  181.      * <p>
  182.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  183.      * </p>
  184.      * <p>
  185.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  186.      * called after this class is loaded, the value will be out of sync with that System property.
  187.      * </p>
  188.      *
  189.      * @see SystemProperties#getJavaCompiler()
  190.      * @since Java 1.2. Not used in Sun versions after 1.2.
  191.      */
  192.     public static final String JAVA_COMPILER = SystemProperties.getJavaCompiler();

  193.     /**
  194.      * A constant for the System Property {@code java.endorsed.dirs}. Path of endorsed directory or directories.
  195.      *
  196.      * <p>
  197.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  198.      * </p>
  199.      * <p>
  200.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  201.      * called after this class is loaded, the value will be out of sync with that System property.
  202.      * </p>
  203.      *
  204.      * @see SystemProperties#getJavaEndorsedDirs()
  205.      * @since Java 1.4
  206.      */
  207.     public static final String JAVA_ENDORSED_DIRS = SystemProperties.getJavaEndorsedDirs();

  208.     /**
  209.      * A constant for the System Property {@code java.ext.dirs}. Path of extension directory or directories.
  210.      *
  211.      * <p>
  212.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  213.      * </p>
  214.      * <p>
  215.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  216.      * called after this class is loaded, the value will be out of sync with that System property.
  217.      * </p>
  218.      *
  219.      * @see SystemProperties#getJavaExtDirs()
  220.      * @since Java 1.3
  221.      */
  222.     public static final String JAVA_EXT_DIRS = SystemProperties.getJavaExtDirs();

  223.     /**
  224.      * A constant for the System Property {@code java.home}. Java installation directory.
  225.      *
  226.      * <p>
  227.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  228.      * </p>
  229.      * <p>
  230.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  231.      * called after this class is loaded, the value will be out of sync with that System property.
  232.      * </p>
  233.      *
  234.      * @see SystemProperties#getJavaHome()
  235.      * @since Java 1.1
  236.      */
  237.     public static final String JAVA_HOME = SystemProperties.getJavaHome();

  238.     /**
  239.      * A constant for the System Property {@code java.io.tmpdir}. Default temp file path.
  240.      *
  241.      * <p>
  242.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  243.      * </p>
  244.      * <p>
  245.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  246.      * called after this class is loaded, the value will be out of sync with that System property.
  247.      * </p>
  248.      *
  249.      * @see SystemProperties#getJavaIoTmpdir()
  250.      * @since Java 1.2
  251.      */
  252.     public static final String JAVA_IO_TMPDIR = SystemProperties.getJavaIoTmpdir();

  253.     /**
  254.      * A constant for the System Property {@code java.library.path}. List of paths to search when loading libraries.
  255.      *
  256.      * <p>
  257.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  258.      * </p>
  259.      * <p>
  260.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  261.      * called after this class is loaded, the value will be out of sync with that System property.
  262.      * </p>
  263.      *
  264.      * @see SystemProperties#getJavaLibraryPath()
  265.      * @since Java 1.2
  266.      */
  267.     public static final String JAVA_LIBRARY_PATH = SystemProperties.getJavaLibraryPath();

  268.     /**
  269.      * A constant for the System Property {@code java.runtime.name}. Java Runtime Environment name.
  270.      *
  271.      * <p>
  272.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  273.      * </p>
  274.      * <p>
  275.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  276.      * called after this class is loaded, the value will be out of sync with that System property.
  277.      * </p>
  278.      *
  279.      * @see SystemProperties#getJavaRuntimeName()
  280.      * @since 2.0
  281.      * @since Java 1.3
  282.      */
  283.     public static final String JAVA_RUNTIME_NAME = SystemProperties.getJavaRuntimeName();

  284.     /**
  285.      * A constant for the System Property {@code java.runtime.version}. Java Runtime Environment version.
  286.      *
  287.      * <p>
  288.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  289.      * </p>
  290.      * <p>
  291.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  292.      * called after this class is loaded, the value will be out of sync with that System property.
  293.      * </p>
  294.      *
  295.      * @see SystemProperties#getJavaRuntimeVersion()
  296.      * @since 2.0
  297.      * @since Java 1.3
  298.      */
  299.     public static final String JAVA_RUNTIME_VERSION = SystemProperties.getJavaRuntimeVersion();

  300.     /**
  301.      * A constant for the System Property {@code java.specification.name}. Java Runtime Environment specification name.
  302.      *
  303.      * <p>
  304.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  305.      * </p>
  306.      * <p>
  307.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  308.      * called after this class is loaded, the value will be out of sync with that System property.
  309.      * </p>
  310.      *
  311.      * @see SystemProperties#getJavaSpecificationName()
  312.      * @since Java 1.2
  313.      */
  314.     public static final String JAVA_SPECIFICATION_NAME = SystemProperties.getJavaSpecificationName();

  315.     /**
  316.      * A constant for the System Property {@code java.specification.vendor}. Java Runtime Environment specification vendor.
  317.      *
  318.      * <p>
  319.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  320.      * </p>
  321.      * <p>
  322.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  323.      * called after this class is loaded, the value will be out of sync with that System property.
  324.      * </p>
  325.      *
  326.      * @see SystemProperties#getJavaSpecificationVendor()
  327.      * @since Java 1.2
  328.      */
  329.     public static final String JAVA_SPECIFICATION_VENDOR = SystemProperties.getJavaSpecificationVendor();

  330.     /**
  331.      * A constant for the System Property {@code java.specification.version}. Java Runtime Environment specification version.
  332.      *
  333.      * <p>
  334.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  335.      * </p>
  336.      * <p>
  337.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  338.      * called after this class is loaded, the value will be out of sync with that System property.
  339.      * </p>
  340.      *
  341.      * @see SystemProperties#getJavaSpecificationVersion()
  342.      * @since Java 1.3
  343.      */
  344.     public static final String JAVA_SPECIFICATION_VERSION = SystemProperties.getJavaSpecificationVersion();

  345.     private static final JavaVersion JAVA_SPECIFICATION_VERSION_AS_ENUM = JavaVersion.get(JAVA_SPECIFICATION_VERSION);

  346.     /**
  347.      * A constant for the System Property {@code java.util.prefs.PreferencesFactory}. A class name.
  348.      *
  349.      * <p>
  350.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  351.      * </p>
  352.      * <p>
  353.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  354.      * called after this class is loaded, the value will be out of sync with that System property.
  355.      * </p>
  356.      *
  357.      * @see SystemProperties#getJavaUtilPrefsPreferencesFactory()
  358.      * @since 2.1
  359.      * @since Java 1.4
  360.      */
  361.     public static final String JAVA_UTIL_PREFS_PREFERENCES_FACTORY = SystemProperties.getJavaUtilPrefsPreferencesFactory();

  362.     /**
  363.      * A constant for the System Property {@code java.vendor}. Java vendor-specific string.
  364.      *
  365.      * <p>
  366.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  367.      * </p>
  368.      * <p>
  369.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  370.      * called after this class is loaded, the value will be out of sync with that System property.
  371.      * </p>
  372.      *
  373.      * @see SystemProperties#getJavaVendor()
  374.      * @since Java 1.1
  375.      */
  376.     public static final String JAVA_VENDOR = SystemProperties.getJavaVendor();

  377.     /**
  378.      * A constant for the System Property {@code java.vendor.url}. Java vendor URL.
  379.      *
  380.      * <p>
  381.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  382.      * </p>
  383.      * <p>
  384.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  385.      * called after this class is loaded, the value will be out of sync with that System property.
  386.      * </p>
  387.      *
  388.      * @see SystemProperties#getJavaVendorUrl()
  389.      * @since Java 1.1
  390.      */
  391.     public static final String JAVA_VENDOR_URL = SystemProperties.getJavaVendorUrl();

  392.     /**
  393.      * A constant for the System Property {@code java.version}. Java version number.
  394.      *
  395.      * <p>
  396.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  397.      * </p>
  398.      * <p>
  399.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  400.      * called after this class is loaded, the value will be out of sync with that System property.
  401.      * </p>
  402.      *
  403.      * @see SystemProperties#getJavaVersion()
  404.      * @since Java 1.1
  405.      */
  406.     public static final String JAVA_VERSION = SystemProperties.getJavaVersion();

  407.     /**
  408.      * A constant for the System Property {@code java.vm.info}. Java Virtual Machine implementation info.
  409.      *
  410.      * <p>
  411.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  412.      * </p>
  413.      * <p>
  414.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  415.      * called after this class is loaded, the value will be out of sync with that System property.
  416.      * </p>
  417.      *
  418.      * @see SystemProperties#getJavaVmInfo()
  419.      * @since 2.0
  420.      * @since Java 1.2
  421.      */
  422.     public static final String JAVA_VM_INFO = SystemProperties.getJavaVmInfo();

  423.     /**
  424.      * A constant for the System Property {@code java.vm.name}. Java Virtual Machine implementation name.
  425.      *
  426.      * <p>
  427.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  428.      * </p>
  429.      * <p>
  430.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  431.      * called after this class is loaded, the value will be out of sync with that System property.
  432.      * </p>
  433.      *
  434.      * @see SystemProperties#getJavaVmName()
  435.      * @since Java 1.2
  436.      */
  437.     public static final String JAVA_VM_NAME = SystemProperties.getJavaVmName();

  438.     /**
  439.      * A constant for the System Property {@code java.vm.specification.name}. Java Virtual Machine specification name.
  440.      *
  441.      * <p>
  442.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  443.      * </p>
  444.      * <p>
  445.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  446.      * called after this class is loaded, the value will be out of sync with that System property.
  447.      * </p>
  448.      *
  449.      * @see SystemProperties#getJavaVmSpecificationName()
  450.      * @since Java 1.2
  451.      */
  452.     public static final String JAVA_VM_SPECIFICATION_NAME = SystemProperties.getJavaVmSpecificationName();

  453.     /**
  454.      * A constant for the System Property {@code java.vm.specification.vendor}. Java Virtual Machine specification vendor.
  455.      *
  456.      * <p>
  457.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  458.      * </p>
  459.      * <p>
  460.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  461.      * called after this class is loaded, the value will be out of sync with that System property.
  462.      * </p>
  463.      *
  464.      * @see SystemProperties#getJavaVmSpecificationVendor()
  465.      * @since Java 1.2
  466.      */
  467.     public static final String JAVA_VM_SPECIFICATION_VENDOR = SystemProperties.getJavaVmSpecificationVendor();

  468.     /**
  469.      * A constant for the System Property {@code java.vm.specification.version}. Java Virtual Machine specification version.
  470.      *
  471.      * <p>
  472.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  473.      * </p>
  474.      * <p>
  475.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  476.      * called after this class is loaded, the value will be out of sync with that System property.
  477.      * </p>
  478.      *
  479.      * @see SystemProperties#getJavaVmSpecificationVersion()
  480.      * @since Java 1.2
  481.      */
  482.     public static final String JAVA_VM_SPECIFICATION_VERSION = SystemProperties.getJavaVmSpecificationVersion();

  483.     /**
  484.      * A constant for the System Property {@code java.vm.vendor}. Java Virtual Machine implementation vendor.
  485.      *
  486.      * <p>
  487.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  488.      * </p>
  489.      * <p>
  490.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  491.      * called after this class is loaded, the value will be out of sync with that System property.
  492.      * </p>
  493.      *
  494.      * @see SystemProperties#getJavaVmVendor()
  495.      * @since Java 1.2
  496.      */
  497.     public static final String JAVA_VM_VENDOR = SystemProperties.getJavaVmVendor();

  498.     /**
  499.      * A constant for the System Property {@code java.vm.version}. Java Virtual Machine implementation version.
  500.      *
  501.      * <p>
  502.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  503.      * </p>
  504.      * <p>
  505.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  506.      * called after this class is loaded, the value will be out of sync with that System property.
  507.      * </p>
  508.      *
  509.      * @see SystemProperties#getJavaVmVersion()
  510.      * @since Java 1.2
  511.      */
  512.     public static final String JAVA_VM_VERSION = SystemProperties.getJavaVmVersion();

  513.     /**
  514.      * A constant for the System Property {@code line.separator}. Line separator ({@code &quot;\n&quot;} on Unix).
  515.      *
  516.      * <p>
  517.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  518.      * </p>
  519.      * <p>
  520.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  521.      * called after this class is loaded, the value will be out of sync with that System property.
  522.      * </p>
  523.      *
  524.      * @see SystemProperties#getLineSeparator()
  525.      * @deprecated Use {@link System#lineSeparator()} instead, since it does not require a privilege check.
  526.      * @since Java 1.1
  527.      */
  528.     @Deprecated
  529.     public static final String LINE_SEPARATOR = SystemProperties.getLineSeparator();

  530.     /**
  531.      * A constant for the System Property {@code os.arch}. Operating system architecture.
  532.      *
  533.      * <p>
  534.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  535.      * </p>
  536.      * <p>
  537.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  538.      * called after this class is loaded, the value will be out of sync with that System property.
  539.      * </p>
  540.      *
  541.      * @see SystemProperties#getOsArch()
  542.      * @since Java 1.1
  543.      */
  544.     public static final String OS_ARCH = SystemProperties.getOsArch();

  545.     /**
  546.      * A constant for the System Property {@code os.name}. Operating system name.
  547.      *
  548.      * <p>
  549.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  550.      * </p>
  551.      * <p>
  552.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  553.      * called after this class is loaded, the value will be out of sync with that System property.
  554.      * </p>
  555.      *
  556.      * @see SystemProperties#getOsName()
  557.      * @since Java 1.1
  558.      */
  559.     public static final String OS_NAME = SystemProperties.getOsName();

  560.     /**
  561.      * A constant for the System Property {@code os.version}. Operating system version.
  562.      *
  563.      * <p>
  564.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  565.      * </p>
  566.      * <p>
  567.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  568.      * called after this class is loaded, the value will be out of sync with that System property.
  569.      * </p>
  570.      *
  571.      * @see SystemProperties#getOsVersion()
  572.      * @since Java 1.1
  573.      */
  574.     public static final String OS_VERSION = SystemProperties.getOsVersion();

  575.     /**
  576.      * A constant for the System Property {@code path.separator}. Path separator ({@code &quot;:&quot;} on Unix).
  577.      *
  578.      * <p>
  579.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  580.      * </p>
  581.      * <p>
  582.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  583.      * called after this class is loaded, the value will be out of sync with that System property.
  584.      * </p>
  585.      *
  586.      * @see SystemProperties#getPathSeparator()
  587.      * @deprecated Use {@link File#pathSeparator}, since it is guaranteed to be a string containing a single character and it does not require a privilege
  588.      *             check.
  589.      * @since Java 1.1
  590.      */
  591.     @Deprecated
  592.     public static final String PATH_SEPARATOR = SystemProperties.getPathSeparator();

  593.     /**
  594.      * A constant for the System Property {@code user.country} or {@code user.region}. User's country code, such as {@code "GB"}. First in Java version 1.2 as
  595.      * {@code user.region}. Renamed to {@code user.country} in 1.4
  596.      *
  597.      * <p>
  598.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  599.      * </p>
  600.      * <p>
  601.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  602.      * called after this class is loaded, the value will be out of sync with that System property.
  603.      * </p>
  604.      *
  605.      * @since 2.0
  606.      * @since Java 1.2
  607.      */
  608.     public static final String USER_COUNTRY = SystemProperties.getProperty(SystemProperties.USER_COUNTRY,
  609.             () -> SystemProperties.getProperty(SystemProperties.USER_REGION));

  610.     /**
  611.      * A constant for the System Property {@code user.dir}. User's current working directory.
  612.      *
  613.      * <p>
  614.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  615.      * </p>
  616.      * <p>
  617.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  618.      * called after this class is loaded, the value will be out of sync with that System property.
  619.      * </p>
  620.      *
  621.      * @see SystemProperties#getUserDir()
  622.      * @since Java 1.1
  623.      */
  624.     public static final String USER_DIR = SystemProperties.getUserDir();

  625.     /**
  626.      * A constant for the System Property {@code user.home}. User's home directory.
  627.      *
  628.      * <p>
  629.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  630.      * </p>
  631.      * <p>
  632.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  633.      * called after this class is loaded, the value will be out of sync with that System property.
  634.      * </p>
  635.      *
  636.      * @see SystemProperties#getUserHome()
  637.      * @since Java 1.1
  638.      */
  639.     public static final String USER_HOME = SystemProperties.getUserHome();

  640.     /**
  641.      * A constant for the System Property {@code user.language}. User's language code, such as {@code "en"}.
  642.      *
  643.      * <p>
  644.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  645.      * </p>
  646.      * <p>
  647.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  648.      * called after this class is loaded, the value will be out of sync with that System property.
  649.      * </p>
  650.      *
  651.      * @see SystemProperties#getUserLanguage()
  652.      * @since 2.0
  653.      * @since Java 1.2
  654.      */
  655.     public static final String USER_LANGUAGE = SystemProperties.getUserLanguage();

  656.     /**
  657.      * A constant for the System Property {@code user.name}. User's account name.
  658.      *
  659.      * <p>
  660.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  661.      * </p>
  662.      * <p>
  663.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  664.      * called after this class is loaded, the value will be out of sync with that System property.
  665.      * </p>
  666.      *
  667.      * @see SystemProperties#getUserName()
  668.      * @since Java 1.1
  669.      */
  670.     public static final String USER_NAME = SystemProperties.getUserName();

  671.     /**
  672.      * A constant for the System Property {@code user.timezone}. For example: {@code "America/Los_Angeles"}.
  673.      *
  674.      * <p>
  675.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  676.      * </p>
  677.      * <p>
  678.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  679.      * called after this class is loaded, the value will be out of sync with that System property.
  680.      * </p>
  681.      *
  682.      * @see SystemProperties#getUserTimezone()
  683.      * @since 2.1
  684.      */
  685.     public static final String USER_TIMEZONE = SystemProperties.getUserTimezone();

  686.     // Java version checks
  687.     // -----------------------------------------------------------------------
  688.     // These MUST be declared after those above as they depend on the
  689.     // values being set up

  690.     /**
  691.      * The constant {@code true} if this is Java version 1.1 (also 1.1.x versions).
  692.      * <p>
  693.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  694.      * </p>
  695.      * <p>
  696.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  697.      * </p>
  698.      * <p>
  699.      * This value is initialized when the class is loaded.
  700.      * </p>
  701.      */
  702.     public static final boolean IS_JAVA_1_1 = getJavaVersionMatches("1.1");

  703.     /**
  704.      * The constant {@code true} if this is Java version 1.2 (also 1.2.x versions).
  705.      * <p>
  706.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  707.      * </p>
  708.      * <p>
  709.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  710.      * </p>
  711.      * <p>
  712.      * This value is initialized when the class is loaded.
  713.      * </p>
  714.      */
  715.     public static final boolean IS_JAVA_1_2 = getJavaVersionMatches("1.2");

  716.     /**
  717.      * The constant {@code true} if this is Java version 1.3 (also 1.3.x versions).
  718.      * <p>
  719.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  720.      * </p>
  721.      * <p>
  722.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  723.      * </p>
  724.      * <p>
  725.      * This value is initialized when the class is loaded.
  726.      * </p>
  727.      */
  728.     public static final boolean IS_JAVA_1_3 = getJavaVersionMatches("1.3");

  729.     /**
  730.      * The constant {@code true} if this is Java version 1.4 (also 1.4.x versions).
  731.      * <p>
  732.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  733.      * </p>
  734.      * <p>
  735.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  736.      * </p>
  737.      * <p>
  738.      * This value is initialized when the class is loaded.
  739.      * </p>
  740.      */
  741.     public static final boolean IS_JAVA_1_4 = getJavaVersionMatches("1.4");

  742.     /**
  743.      * The constant {@code true} if this is Java version 1.5 (also 1.5.x versions).
  744.      * <p>
  745.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  746.      * </p>
  747.      * <p>
  748.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  749.      * </p>
  750.      * <p>
  751.      * This value is initialized when the class is loaded.
  752.      * </p>
  753.      */
  754.     public static final boolean IS_JAVA_1_5 = getJavaVersionMatches("1.5");

  755.     /**
  756.      * The constant {@code true} if this is Java version 1.6 (also 1.6.x versions).
  757.      * <p>
  758.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  759.      * </p>
  760.      * <p>
  761.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  762.      * </p>
  763.      * <p>
  764.      * This value is initialized when the class is loaded.
  765.      * </p>
  766.      */
  767.     public static final boolean IS_JAVA_1_6 = getJavaVersionMatches("1.6");

  768.     /**
  769.      * The constant {@code true} if this is Java version 1.7 (also 1.7.x versions).
  770.      * <p>
  771.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  772.      * </p>
  773.      * <p>
  774.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  775.      * </p>
  776.      * <p>
  777.      * This value is initialized when the class is loaded.
  778.      * </p>
  779.      *
  780.      * @since 3.0
  781.      */
  782.     public static final boolean IS_JAVA_1_7 = getJavaVersionMatches("1.7");

  783.     /**
  784.      * The constant {@code true} if this is Java version 1.8 (also 1.8.x versions).
  785.      * <p>
  786.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  787.      * </p>
  788.      * <p>
  789.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  790.      * </p>
  791.      * <p>
  792.      * This value is initialized when the class is loaded.
  793.      * </p>
  794.      *
  795.      * @since 3.3.2
  796.      */
  797.     public static final boolean IS_JAVA_1_8 = getJavaVersionMatches("1.8");

  798.     /**
  799.      * The constant {@code true} if this is Java version 1.9 (also 1.9.x versions).
  800.      * <p>
  801.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  802.      * </p>
  803.      * <p>
  804.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  805.      * </p>
  806.      * <p>
  807.      * This value is initialized when the class is loaded.
  808.      * </p>
  809.      *
  810.      * @since 3.4
  811.      * @deprecated As of release 3.5, replaced by {@link #IS_JAVA_9}
  812.      */
  813.     @Deprecated
  814.     public static final boolean IS_JAVA_1_9 = getJavaVersionMatches("9");

  815.     /**
  816.      * The constant {@code true} if this is Java version 9 (also 9.x versions).
  817.      * <p>
  818.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  819.      * </p>
  820.      * <p>
  821.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  822.      * </p>
  823.      * <p>
  824.      * This value is initialized when the class is loaded.
  825.      * </p>
  826.      *
  827.      * @since 3.5
  828.      */
  829.     public static final boolean IS_JAVA_9 = getJavaVersionMatches("9");

  830.     /**
  831.      * The constant {@code true} if this is Java version 10 (also 10.x versions).
  832.      * <p>
  833.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  834.      * </p>
  835.      * <p>
  836.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  837.      * </p>
  838.      * <p>
  839.      * This value is initialized when the class is loaded.
  840.      * </p>
  841.      *
  842.      * @since 3.7
  843.      */
  844.     public static final boolean IS_JAVA_10 = getJavaVersionMatches("10");

  845.     /**
  846.      * The constant {@code true} if this is Java version 11 (also 11.x versions).
  847.      * <p>
  848.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  849.      * </p>
  850.      * <p>
  851.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  852.      * </p>
  853.      * <p>
  854.      * This value is initialized when the class is loaded.
  855.      * </p>
  856.      *
  857.      * @since 3.8
  858.      */
  859.     public static final boolean IS_JAVA_11 = getJavaVersionMatches("11");

  860.     /**
  861.      * The constant {@code true} if this is Java version 12 (also 12.x versions).
  862.      * <p>
  863.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  864.      * </p>
  865.      * <p>
  866.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  867.      * </p>
  868.      * <p>
  869.      * This value is initialized when the class is loaded.
  870.      * </p>
  871.      *
  872.      * @since 3.9
  873.      */
  874.     public static final boolean IS_JAVA_12 = getJavaVersionMatches("12");

  875.     /**
  876.      * The constant {@code true} if this is Java version 13 (also 13.x versions).
  877.      * <p>
  878.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  879.      * </p>
  880.      * <p>
  881.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  882.      * </p>
  883.      * <p>
  884.      * This value is initialized when the class is loaded.
  885.      * </p>
  886.      *
  887.      * @since 3.9
  888.      */
  889.     public static final boolean IS_JAVA_13 = getJavaVersionMatches("13");

  890.     /**
  891.      * The constant {@code true} if this is Java version 14 (also 14.x versions).
  892.      * <p>
  893.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  894.      * </p>
  895.      * <p>
  896.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  897.      * </p>
  898.      * <p>
  899.      * This value is initialized when the class is loaded.
  900.      * </p>
  901.      *
  902.      * @since 3.10
  903.      */
  904.     public static final boolean IS_JAVA_14 = getJavaVersionMatches("14");

  905.     /**
  906.      * The constant {@code true} if this is Java version 15 (also 15.x versions).
  907.      * <p>
  908.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  909.      * </p>
  910.      * <p>
  911.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  912.      * </p>
  913.      * <p>
  914.      * This value is initialized when the class is loaded.
  915.      * </p>
  916.      *
  917.      * @since 3.10
  918.      */
  919.     public static final boolean IS_JAVA_15 = getJavaVersionMatches("15");

  920.     /**
  921.      * The constant {@code true} if this is Java version 16 (also 16.x versions).
  922.      * <p>
  923.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  924.      * </p>
  925.      * <p>
  926.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  927.      * </p>
  928.      * <p>
  929.      * This value is initialized when the class is loaded.
  930.      * </p>
  931.      *
  932.      * @since 3.13.0
  933.      */
  934.     public static final boolean IS_JAVA_16 = getJavaVersionMatches("16");

  935.     /**
  936.      * The constant {@code true} if this is Java version 17 (also 17.x versions).
  937.      * <p>
  938.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  939.      * </p>
  940.      * <p>
  941.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  942.      * </p>
  943.      * <p>
  944.      * This value is initialized when the class is loaded.
  945.      * </p>
  946.      *
  947.      * @since 3.13.0
  948.      */
  949.     public static final boolean IS_JAVA_17 = getJavaVersionMatches("17");

  950.     /**
  951.      * The constant {@code true} if this is Java version 18 (also 18.x versions).
  952.      * <p>
  953.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  954.      * </p>
  955.      * <p>
  956.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  957.      * </p>
  958.      * <p>
  959.      * This value is initialized when the class is loaded.
  960.      * </p>
  961.      *
  962.      * @since 3.13.0
  963.      */
  964.     public static final boolean IS_JAVA_18 = getJavaVersionMatches("18");

  965.     /**
  966.      * The constant {@code true} if this is Java version 19 (also 19.x versions).
  967.      * <p>
  968.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  969.      * </p>
  970.      * <p>
  971.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  972.      * </p>
  973.      * <p>
  974.      * This value is initialized when the class is loaded.
  975.      * </p>
  976.      *
  977.      * @since 3.13.0
  978.      */
  979.     public static final boolean IS_JAVA_19 = getJavaVersionMatches("19");

  980.     /**
  981.      * The constant {@code true} if this is Java version 20 (also 20.x versions).
  982.      * <p>
  983.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  984.      * </p>
  985.      * <p>
  986.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  987.      * </p>
  988.      * <p>
  989.      * This value is initialized when the class is loaded.
  990.      * </p>
  991.      *
  992.      * @since 3.13.0
  993.      */
  994.     public static final boolean IS_JAVA_20 = getJavaVersionMatches("20");

  995.     /**
  996.      * The constant {@code true} if this is Java version 21 (also 21.x versions).
  997.      * <p>
  998.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  999.      * </p>
  1000.      * <p>
  1001.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  1002.      * </p>
  1003.      * <p>
  1004.      * This value is initialized when the class is loaded.
  1005.      * </p>
  1006.      *
  1007.      * @since 3.13.0
  1008.      */
  1009.     public static final boolean IS_JAVA_21 = getJavaVersionMatches("21");

  1010.     /**
  1011.      * The constant {@code true} if this is Java version 22 (also 22.x versions).
  1012.      * <p>
  1013.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  1014.      * </p>
  1015.      * <p>
  1016.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  1017.      * </p>
  1018.      * <p>
  1019.      * This value is initialized when the class is loaded.
  1020.      * </p>
  1021.      *
  1022.      * @since 3.15.0
  1023.      */
  1024.     public static final boolean IS_JAVA_22 = getJavaVersionMatches("22");

  1025.     /**
  1026.      * The constant {@code true} if this is Java version 23 (also 23.x versions).
  1027.      * <p>
  1028.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  1029.      * </p>
  1030.      * <p>
  1031.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  1032.      * </p>
  1033.      * <p>
  1034.      * This value is initialized when the class is loaded.
  1035.      * </p>
  1036.      *
  1037.      * @since 3.18.0
  1038.      */
  1039.     public static final boolean IS_JAVA_23 = getJavaVersionMatches("23");

  1040.     /**
  1041.      * The constant {@code true} if this is Java version 24 (also 24.x versions).
  1042.      * <p>
  1043.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  1044.      * </p>
  1045.      * <p>
  1046.      * The field will return {@code false} if {@link #JAVA_SPECIFICATION_VERSION} is {@code null}.
  1047.      * </p>
  1048.      * <p>
  1049.      * This value is initialized when the class is loaded.
  1050.      * </p>
  1051.      *
  1052.      * @since 3.18.0
  1053.      */
  1054.     public static final boolean IS_JAVA_24 = getJavaVersionMatches("24");

  1055.     // Operating system checks
  1056.     // -----------------------------------------------------------------------
  1057.     // These MUST be declared after those above as they depend on the
  1058.     // values being set up
  1059.     // Please advise dev@commons.apache.org if you want another added
  1060.     // or a mistake corrected

  1061.     /**
  1062.      * The constant {@code true} if this is AIX.
  1063.      * <p>
  1064.      * The result depends on the value of the {@link #OS_NAME} constant.
  1065.      * </p>
  1066.      * <p>
  1067.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1068.      * </p>
  1069.      * <p>
  1070.      * This value is initialized when the class is loaded.
  1071.      * </p>
  1072.      *
  1073.      * @since 2.0
  1074.      */
  1075.     public static final boolean IS_OS_AIX = getOsNameMatches("AIX");

  1076.     /**
  1077.      * The constant {@code true} if this is Android.
  1078.      *
  1079.      * <p>
  1080.      * See https://developer.android.com/reference/java/lang/System#getProperties().
  1081.      * </p>
  1082.      * <p>
  1083.      * This value is initialized when the class is loaded.
  1084.      * </p>
  1085.      *
  1086.      * @since 3.15.0
  1087.      */
  1088.     public static final boolean IS_OS_ANDROID = Strings.CS.contains(SystemProperties.getJavaVendor(), "Android");

  1089.     /**
  1090.      * The constant {@code true} if this is HP-UX.
  1091.      * <p>
  1092.      * The result depends on the value of the {@link #OS_NAME} constant.
  1093.      * </p>
  1094.      * <p>
  1095.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1096.      * </p>
  1097.      * <p>
  1098.      * This value is initialized when the class is loaded.
  1099.      * </p>
  1100.      *
  1101.      * @since 2.0
  1102.      */
  1103.     public static final boolean IS_OS_HP_UX = getOsNameMatches("HP-UX");

  1104.     /**
  1105.      * The constant {@code true} if this is IBM OS/400.
  1106.      * <p>
  1107.      * The result depends on the value of the {@link #OS_NAME} constant.
  1108.      * </p>
  1109.      * <p>
  1110.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1111.      * </p>
  1112.      * <p>
  1113.      * This value is initialized when the class is loaded.
  1114.      * </p>
  1115.      *
  1116.      * @since 3.3
  1117.      */
  1118.     public static final boolean IS_OS_400 = getOsNameMatches("OS/400");

  1119.     /**
  1120.      * The constant {@code true} if this is Irix.
  1121.      * <p>
  1122.      * The result depends on the value of the {@link #OS_NAME} constant.
  1123.      * </p>
  1124.      * <p>
  1125.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1126.      * </p>
  1127.      * <p>
  1128.      * This value is initialized when the class is loaded.
  1129.      * </p>
  1130.      *
  1131.      * @since 2.0
  1132.      */
  1133.     public static final boolean IS_OS_IRIX = getOsNameMatches("Irix");

  1134.     /**
  1135.      * The constant {@code true} if this is Linux.
  1136.      * <p>
  1137.      * The result depends on the value of the {@link #OS_NAME} constant.
  1138.      * </p>
  1139.      * <p>
  1140.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1141.      * </p>
  1142.      * <p>
  1143.      * This value is initialized when the class is loaded.
  1144.      * </p>
  1145.      *
  1146.      * @since 2.0
  1147.      */
  1148.     public static final boolean IS_OS_LINUX = getOsNameMatches("Linux");

  1149.     /**
  1150.      * The constant {@code true} if this is Mac.
  1151.      * <p>
  1152.      * The result depends on the value of the {@link #OS_NAME} constant.
  1153.      * </p>
  1154.      * <p>
  1155.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1156.      * </p>
  1157.      * <p>
  1158.      * This value is initialized when the class is loaded.
  1159.      * </p>
  1160.      *
  1161.      * @since 2.0
  1162.      */
  1163.     public static final boolean IS_OS_MAC = getOsNameMatches("Mac");

  1164.     /**
  1165.      * The constant {@code true} if this is Mac.
  1166.      * <p>
  1167.      * The result depends on the value of the {@link #OS_NAME} constant.
  1168.      * </p>
  1169.      * <p>
  1170.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1171.      * </p>
  1172.      * <p>
  1173.      * This value is initialized when the class is loaded.
  1174.      * </p>
  1175.      *
  1176.      * @since 2.0
  1177.      */
  1178.     public static final boolean IS_OS_MAC_OSX = getOsNameMatches("Mac OS X");

  1179.     /**
  1180.      * The constant {@code true} if this is macOS X Cheetah.
  1181.      * <p>
  1182.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1183.      * </p>
  1184.      * <p>
  1185.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1186.      * </p>
  1187.      * <p>
  1188.      * This value is initialized when the class is loaded.
  1189.      * </p>
  1190.      *
  1191.      * @since 3.4
  1192.      */
  1193.     public static final boolean IS_OS_MAC_OSX_CHEETAH = getOsMatches("Mac OS X", "10.0");

  1194.     /**
  1195.      * The constant {@code true} if this is macOS X Puma.
  1196.      * <p>
  1197.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1198.      * </p>
  1199.      * <p>
  1200.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1201.      * </p>
  1202.      * <p>
  1203.      * This value is initialized when the class is loaded.
  1204.      * </p>
  1205.      *
  1206.      * @since 3.4
  1207.      */
  1208.     public static final boolean IS_OS_MAC_OSX_PUMA = getOsMatches("Mac OS X", "10.1");

  1209.     /**
  1210.      * The constant {@code true} if this is macOS X Jaguar.
  1211.      * <p>
  1212.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1213.      * </p>
  1214.      * <p>
  1215.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1216.      * </p>
  1217.      * <p>
  1218.      * This value is initialized when the class is loaded.
  1219.      * </p>
  1220.      *
  1221.      * @since 3.4
  1222.      */
  1223.     public static final boolean IS_OS_MAC_OSX_JAGUAR = getOsMatches("Mac OS X", "10.2");

  1224.     /**
  1225.      * The constant {@code true} if this is macOS X Panther.
  1226.      * <p>
  1227.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1228.      * </p>
  1229.      * <p>
  1230.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1231.      * </p>
  1232.      * <p>
  1233.      * This value is initialized when the class is loaded.
  1234.      * </p>
  1235.      *
  1236.      * @since 3.4
  1237.      */
  1238.     public static final boolean IS_OS_MAC_OSX_PANTHER = getOsMatches("Mac OS X", "10.3");

  1239.     /**
  1240.      * The constant {@code true} if this is macOS X Tiger.
  1241.      * <p>
  1242.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1243.      * </p>
  1244.      * <p>
  1245.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1246.      * </p>
  1247.      * <p>
  1248.      * This value is initialized when the class is loaded.
  1249.      * </p>
  1250.      *
  1251.      * @since 3.4
  1252.      */
  1253.     public static final boolean IS_OS_MAC_OSX_TIGER = getOsMatches("Mac OS X", "10.4");

  1254.     /**
  1255.      * The constant {@code true} if this is macOS X Leopard.
  1256.      * <p>
  1257.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1258.      * </p>
  1259.      * <p>
  1260.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1261.      * </p>
  1262.      * <p>
  1263.      * This value is initialized when the class is loaded.
  1264.      * </p>
  1265.      *
  1266.      * @since 3.4
  1267.      */
  1268.     public static final boolean IS_OS_MAC_OSX_LEOPARD = getOsMatches("Mac OS X", "10.5");

  1269.     /**
  1270.      * The constant {@code true} if this is macOS X Snow Leopard.
  1271.      * <p>
  1272.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1273.      * </p>
  1274.      * <p>
  1275.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1276.      * </p>
  1277.      * <p>
  1278.      * This value is initialized when the class is loaded.
  1279.      * </p>
  1280.      *
  1281.      * @since 3.4
  1282.      */
  1283.     public static final boolean IS_OS_MAC_OSX_SNOW_LEOPARD = getOsMatches("Mac OS X", "10.6");

  1284.     /**
  1285.      * The constant {@code true} if this is macOS X Lion.
  1286.      * <p>
  1287.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1288.      * </p>
  1289.      * <p>
  1290.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1291.      * </p>
  1292.      * <p>
  1293.      * This value is initialized when the class is loaded.
  1294.      * </p>
  1295.      *
  1296.      * @since 3.4
  1297.      */
  1298.     public static final boolean IS_OS_MAC_OSX_LION = getOsMatches("Mac OS X", "10.7");

  1299.     /**
  1300.      * The constant {@code true} if this is macOS X Mountain Lion.
  1301.      * <p>
  1302.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1303.      * </p>
  1304.      * <p>
  1305.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1306.      * </p>
  1307.      * <p>
  1308.      * This value is initialized when the class is loaded.
  1309.      * </p>
  1310.      *
  1311.      * @since 3.4
  1312.      */
  1313.     public static final boolean IS_OS_MAC_OSX_MOUNTAIN_LION = getOsMatches("Mac OS X", "10.8");

  1314.     /**
  1315.      * The constant {@code true} if this is macOS X Mavericks.
  1316.      * <p>
  1317.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1318.      * </p>
  1319.      * <p>
  1320.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1321.      * </p>
  1322.      * <p>
  1323.      * This value is initialized when the class is loaded.
  1324.      * </p>
  1325.      *
  1326.      * @since 3.4
  1327.      */
  1328.     public static final boolean IS_OS_MAC_OSX_MAVERICKS = getOsMatches("Mac OS X", "10.9");

  1329.     /**
  1330.      * The constant {@code true} if this is macOS X Yosemite.
  1331.      * <p>
  1332.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1333.      * </p>
  1334.      * <p>
  1335.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1336.      * </p>
  1337.      * <p>
  1338.      * This value is initialized when the class is loaded.
  1339.      * </p>
  1340.      *
  1341.      * @since 3.4
  1342.      */
  1343.     public static final boolean IS_OS_MAC_OSX_YOSEMITE = getOsMatches("Mac OS X", "10.10");

  1344.     /**
  1345.      * The constant {@code true} if this is macOS X El Capitan.
  1346.      * <p>
  1347.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1348.      * </p>
  1349.      * <p>
  1350.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1351.      * </p>
  1352.      * <p>
  1353.      * This value is initialized when the class is loaded.
  1354.      * </p>
  1355.      *
  1356.      * @since 3.5
  1357.      */
  1358.     public static final boolean IS_OS_MAC_OSX_EL_CAPITAN = getOsMatches("Mac OS X", "10.11");

  1359.     /**
  1360.      * The constant {@code true} if this is macOS X Sierra.
  1361.      * <p>
  1362.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1363.      * </p>
  1364.      * <p>
  1365.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1366.      * </p>
  1367.      * <p>
  1368.      * This value is initialized when the class is loaded.
  1369.      * </p>
  1370.      *
  1371.      * @since 3.12.0
  1372.      */
  1373.     public static final boolean IS_OS_MAC_OSX_SIERRA = getOsMatches("Mac OS X", "10.12");

  1374.     /**
  1375.      * The constant {@code true} if this is macOS X High Sierra.
  1376.      * <p>
  1377.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1378.      * </p>
  1379.      * <p>
  1380.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1381.      * </p>
  1382.      * <p>
  1383.      * This value is initialized when the class is loaded.
  1384.      * </p>
  1385.      *
  1386.      * @since 3.12.0
  1387.      */
  1388.     public static final boolean IS_OS_MAC_OSX_HIGH_SIERRA = getOsMatches("Mac OS X", "10.13");

  1389.     /**
  1390.      * The constant {@code true} if this is macOS X Mojave.
  1391.      * <p>
  1392.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1393.      * </p>
  1394.      * <p>
  1395.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1396.      * </p>
  1397.      * <p>
  1398.      * This value is initialized when the class is loaded.
  1399.      * </p>
  1400.      *
  1401.      * @since 3.12.0
  1402.      */
  1403.     public static final boolean IS_OS_MAC_OSX_MOJAVE = getOsMatches("Mac OS X", "10.14");

  1404.     /**
  1405.      * The constant {@code true} if this is macOS X Catalina.
  1406.      *
  1407.      * <p>
  1408.      * The field will return {@code false} if {@code OS_NAME} is {@code null}.
  1409.      * </p>
  1410.      * <p>
  1411.      * This value is initialized when the class is loaded.
  1412.      * </p>
  1413.      *
  1414.      * @since 3.12.0
  1415.      */
  1416.     public static final boolean IS_OS_MAC_OSX_CATALINA = getOsMatches("Mac OS X", "10.15");

  1417.     /**
  1418.      * The constant {@code true} if this is macOS X Big Sur.
  1419.      * <p>
  1420.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1421.      * </p>
  1422.      * <p>
  1423.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1424.      * </p>
  1425.      * <p>
  1426.      * This value is initialized when the class is loaded.
  1427.      * </p>
  1428.      *
  1429.      * @since 3.12.0
  1430.      */
  1431.     public static final boolean IS_OS_MAC_OSX_BIG_SUR = getOsMatches("Mac OS X", "11");

  1432.     /**
  1433.      * The constant {@code true} if this is macOS X Monterey.
  1434.      * <p>
  1435.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1436.      * </p>
  1437.      * <p>
  1438.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1439.      * </p>
  1440.      * <p>
  1441.      * This value is initialized when the class is loaded.
  1442.      * </p>
  1443.      *
  1444.      * @since 3.13.0
  1445.      */
  1446.     public static final boolean IS_OS_MAC_OSX_MONTEREY = getOsMatches("Mac OS X", "12");

  1447.     /**
  1448.      * The constant {@code true} if this is macOS X Ventura.
  1449.      * <p>
  1450.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1451.      * </p>
  1452.      * <p>
  1453.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1454.      * </p>
  1455.      * <p>
  1456.      * This value is initialized when the class is loaded.
  1457.      * </p>
  1458.      *
  1459.      * @since 3.13.0
  1460.      */
  1461.     public static final boolean IS_OS_MAC_OSX_VENTURA = getOsMatches("Mac OS X", "13");

  1462.     /**
  1463.      * The constant {@code true} if this is macOS X Sonoma.
  1464.      * <p>
  1465.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1466.      * </p>
  1467.      * <p>
  1468.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1469.      * </p>
  1470.      * <p>
  1471.      * This value is initialized when the class is loaded.
  1472.      * </p>
  1473.      *
  1474.      * @since 3.15.0
  1475.      */
  1476.     public static final boolean IS_OS_MAC_OSX_SONOMA = getOsMatches("Mac OS X", "14");

  1477.     /**
  1478.      * The constant {@code true} if this is macOS X Sequoia.
  1479.      * <p>
  1480.      * The value depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1481.      * </p>
  1482.      * <p>
  1483.      * The value is {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1484.      * </p>
  1485.      * <p>
  1486.      * This value is initialized when the class is loaded.
  1487.      * </p>
  1488.      *
  1489.      * @since 3.18.0
  1490.      */
  1491.     public static final boolean IS_OS_MAC_OSX_SEQUOIA = getOsMatches("Mac OS X", "15");

  1492.     /**
  1493.      * The constant {@code true} if this is FreeBSD.
  1494.      * <p>
  1495.      * The result depends on the value of the {@link #OS_NAME} constant.
  1496.      * </p>
  1497.      * <p>
  1498.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1499.      * </p>
  1500.      * <p>
  1501.      * This value is initialized when the class is loaded.
  1502.      * </p>
  1503.      *
  1504.      * @since 3.1
  1505.      */
  1506.     public static final boolean IS_OS_FREE_BSD = getOsNameMatches("FreeBSD");

  1507.     /**
  1508.      * The constant {@code true} if this is OpenBSD.
  1509.      * <p>
  1510.      * The result depends on the value of the {@link #OS_NAME} constant.
  1511.      * </p>
  1512.      * <p>
  1513.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1514.      * </p>
  1515.      * <p>
  1516.      * This value is initialized when the class is loaded.
  1517.      * </p>
  1518.      *
  1519.      * @since 3.1
  1520.      */
  1521.     public static final boolean IS_OS_OPEN_BSD = getOsNameMatches("OpenBSD");

  1522.     /**
  1523.      * The constant {@code true} if this is NetBSD.
  1524.      * <p>
  1525.      * The result depends on the value of the {@link #OS_NAME} constant.
  1526.      * </p>
  1527.      * <p>
  1528.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1529.      * </p>
  1530.      * <p>
  1531.      * This value is initialized when the class is loaded.
  1532.      * </p>
  1533.      *
  1534.      * @since 3.1
  1535.      */
  1536.     public static final boolean IS_OS_NET_BSD = getOsNameMatches("NetBSD");

  1537.     /**
  1538.      * The constant {@code true} if this is OS/2.
  1539.      * <p>
  1540.      * The result depends on the value of the {@link #OS_NAME} constant.
  1541.      * </p>
  1542.      * <p>
  1543.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1544.      * </p>
  1545.      * <p>
  1546.      * This value is initialized when the class is loaded.
  1547.      * </p>
  1548.      *
  1549.      * @since 2.0
  1550.      */
  1551.     public static final boolean IS_OS_OS2 = getOsNameMatches("OS/2");

  1552.     /**
  1553.      * The constant {@code true} if this is Solaris.
  1554.      * <p>
  1555.      * The result depends on the value of the {@link #OS_NAME} constant.
  1556.      * </p>
  1557.      * <p>
  1558.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1559.      * </p>
  1560.      * <p>
  1561.      * This value is initialized when the class is loaded.
  1562.      * </p>
  1563.      *
  1564.      * @since 2.0
  1565.      */
  1566.     public static final boolean IS_OS_SOLARIS = getOsNameMatches("Solaris");

  1567.     /**
  1568.      * The constant {@code true} if this is SunOS.
  1569.      * <p>
  1570.      * The result depends on the value of the {@link #OS_NAME} constant.
  1571.      * </p>
  1572.      * <p>
  1573.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1574.      * </p>
  1575.      * <p>
  1576.      * This value is initialized when the class is loaded.
  1577.      * </p>
  1578.      *
  1579.      * @since 2.0
  1580.      */
  1581.     public static final boolean IS_OS_SUN_OS = getOsNameMatches("SunOS");

  1582.     /**
  1583.      * The constant {@code true} if this is a Unix like system, as in any of AIX, HP-UX, Irix, Linux, MacOSX, Solaris or SUN OS.
  1584.      *
  1585.      * <p>
  1586.      * The field will return {@code false} if {@code OS_NAME} is {@code null}.
  1587.      * </p>
  1588.      * <p>
  1589.      * This value is initialized when the class is loaded.
  1590.      * </p>
  1591.      *
  1592.      * @since 2.1
  1593.      */
  1594.     public static final boolean IS_OS_UNIX = IS_OS_AIX || IS_OS_HP_UX || IS_OS_IRIX || IS_OS_LINUX || IS_OS_MAC_OSX || IS_OS_SOLARIS || IS_OS_SUN_OS
  1595.             || IS_OS_FREE_BSD || IS_OS_OPEN_BSD || IS_OS_NET_BSD;

  1596.     /**
  1597.      * The constant {@code true} if this is Windows.
  1598.      * <p>
  1599.      * The result depends on the value of the {@link #OS_NAME} constant.
  1600.      * </p>
  1601.      * <p>
  1602.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1603.      * </p>
  1604.      * <p>
  1605.      * This value is initialized when the class is loaded.
  1606.      * </p>
  1607.      *
  1608.      * @since 2.0
  1609.      */
  1610.     public static final boolean IS_OS_WINDOWS = getOsNameMatches(OS_NAME_WINDOWS_PREFIX);

  1611.     /**
  1612.      * The constant {@code true} if this is Windows 2000.
  1613.      * <p>
  1614.      * The result depends on the value of the {@link #OS_NAME} constant.
  1615.      * </p>
  1616.      * <p>
  1617.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1618.      * </p>
  1619.      * <p>
  1620.      * This value is initialized when the class is loaded.
  1621.      * </p>
  1622.      *
  1623.      * @since 2.0
  1624.      */
  1625.     public static final boolean IS_OS_WINDOWS_2000 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 2000");

  1626.     /**
  1627.      * The constant {@code true} if this is Windows 2003.
  1628.      * <p>
  1629.      * The result depends on the value of the {@link #OS_NAME} constant.
  1630.      * </p>
  1631.      * <p>
  1632.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1633.      * </p>
  1634.      * <p>
  1635.      * This value is initialized when the class is loaded.
  1636.      * </p>
  1637.      *
  1638.      * @since 3.1
  1639.      */
  1640.     public static final boolean IS_OS_WINDOWS_2003 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 2003");

  1641.     /**
  1642.      * The constant {@code true} if this is Windows Server 2008.
  1643.      * <p>
  1644.      * The result depends on the value of the {@link #OS_NAME} constant.
  1645.      * </p>
  1646.      * <p>
  1647.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1648.      * </p>
  1649.      * <p>
  1650.      * This value is initialized when the class is loaded.
  1651.      * </p>
  1652.      *
  1653.      * @since 3.1
  1654.      */
  1655.     public static final boolean IS_OS_WINDOWS_2008 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " Server 2008");

  1656.     /**
  1657.      * The constant {@code true} if this is Windows Server 2012.
  1658.      * <p>
  1659.      * The result depends on the value of the {@link #OS_NAME} constant.
  1660.      * </p>
  1661.      * <p>
  1662.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1663.      * </p>
  1664.      * <p>
  1665.      * This value is initialized when the class is loaded.
  1666.      * </p>
  1667.      *
  1668.      * @since 3.4
  1669.      */
  1670.     public static final boolean IS_OS_WINDOWS_2012 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " Server 2012");

  1671.     /**
  1672.      * The constant {@code true} if this is Windows 95.
  1673.      * <p>
  1674.      * The result depends on the value of the {@link #OS_NAME} constant.
  1675.      * </p>
  1676.      * <p>
  1677.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1678.      * </p>
  1679.      * <p>
  1680.      * This value is initialized when the class is loaded.
  1681.      * </p>
  1682.      *
  1683.      * @since 2.0
  1684.      */
  1685.     public static final boolean IS_OS_WINDOWS_95 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 95");

  1686.     /**
  1687.      * The constant {@code true} if this is Windows 98.
  1688.      * <p>
  1689.      * The result depends on the value of the {@link #OS_NAME} constant.
  1690.      * </p>
  1691.      * <p>
  1692.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1693.      * </p>
  1694.      * <p>
  1695.      * This value is initialized when the class is loaded.
  1696.      * </p>
  1697.      *
  1698.      * @since 2.0
  1699.      */
  1700.     public static final boolean IS_OS_WINDOWS_98 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 98");

  1701.     /**
  1702.      * The constant {@code true} if this is Windows ME.
  1703.      * <p>
  1704.      * The result depends on the value of the {@link #OS_NAME} constant.
  1705.      * </p>
  1706.      * <p>
  1707.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1708.      * </p>
  1709.      * <p>
  1710.      * This value is initialized when the class is loaded.
  1711.      * </p>
  1712.      *
  1713.      * @since 2.0
  1714.      */
  1715.     public static final boolean IS_OS_WINDOWS_ME = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " Me");

  1716.     /**
  1717.      * The constant {@code true} if this is Windows NT.
  1718.      * <p>
  1719.      * The result depends on the value of the {@link #OS_NAME} constant.
  1720.      * </p>
  1721.      * <p>
  1722.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1723.      * </p>
  1724.      * <p>
  1725.      * This value is initialized when the class is loaded.
  1726.      * </p>
  1727.      *
  1728.      * @since 2.0
  1729.      */
  1730.     public static final boolean IS_OS_WINDOWS_NT = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " NT");

  1731.     /**
  1732.      * The constant {@code true} if this is Windows XP.
  1733.      * <p>
  1734.      * The result depends on the value of the {@link #OS_NAME} constant.
  1735.      * </p>
  1736.      * <p>
  1737.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1738.      * </p>
  1739.      * <p>
  1740.      * This value is initialized when the class is loaded.
  1741.      * </p>
  1742.      *
  1743.      * @since 2.0
  1744.      */
  1745.     public static final boolean IS_OS_WINDOWS_XP = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " XP");

  1746.     /**
  1747.      * The constant {@code true} if this is Windows Vista.
  1748.      * <p>
  1749.      * The result depends on the value of the {@link #OS_NAME} constant.
  1750.      * </p>
  1751.      * <p>
  1752.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1753.      * </p>
  1754.      * <p>
  1755.      * This value is initialized when the class is loaded.
  1756.      * </p>
  1757.      *
  1758.      * @since 2.4
  1759.      */
  1760.     public static final boolean IS_OS_WINDOWS_VISTA = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " Vista");

  1761.     /**
  1762.      * The constant {@code true} if this is Windows 7.
  1763.      * <p>
  1764.      * The result depends on the value of the {@link #OS_NAME} constant.
  1765.      * </p>
  1766.      * <p>
  1767.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1768.      * </p>
  1769.      * <p>
  1770.      * This value is initialized when the class is loaded.
  1771.      * </p>
  1772.      *
  1773.      * @since 3.0
  1774.      */
  1775.     public static final boolean IS_OS_WINDOWS_7 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 7");

  1776.     /**
  1777.      * The constant {@code true} if this is Windows 8.
  1778.      * <p>
  1779.      * The result depends on the value of the {@link #OS_NAME} constant.
  1780.      * </p>
  1781.      * <p>
  1782.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1783.      * </p>
  1784.      * <p>
  1785.      * This value is initialized when the class is loaded.
  1786.      * </p>
  1787.      *
  1788.      * @since 3.2
  1789.      */
  1790.     public static final boolean IS_OS_WINDOWS_8 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 8");

  1791.     /**
  1792.      * The constant {@code true} if this is Windows 10.
  1793.      * <p>
  1794.      * The result depends on the value of the {@link #OS_NAME} constant.
  1795.      * </p>
  1796.      * <p>
  1797.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1798.      * </p>
  1799.      * <p>
  1800.      * This value is initialized when the class is loaded.
  1801.      * </p>
  1802.      *
  1803.      * @since 3.5
  1804.      */
  1805.     public static final boolean IS_OS_WINDOWS_10 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 10");

  1806.     /**
  1807.      * The constant {@code true} if this is Windows 11.
  1808.      * <p>
  1809.      * The result depends on the value of the {@link #OS_NAME} constant.
  1810.      * </p>
  1811.      * <p>
  1812.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1813.      * </p>
  1814.      * <p>
  1815.      * OpenJDK fixed the return value for {@code os.name} on Windows 11 to versions 8, 11, and 17:
  1816.      * </p>
  1817.      * <ul>
  1818.      * <li>Affects Java versions 7u321, 8u311, 11.0.13-oracle, 17.0.1: https://bugs.openjdk.org/browse/JDK-8274737</li>
  1819.      * <li>Fixed in OpenJDK commit https://github.com/openjdk/jdk/commit/97ea9dd2f24f9f1fb9b9345a4202a825ee28e014</li>
  1820.      * </ul>
  1821.      * <p>
  1822.      * This value is initialized when the class is loaded.
  1823.      * </p>
  1824.      *
  1825.      * @since 3.13.0
  1826.      */
  1827.     public static final boolean IS_OS_WINDOWS_11 = getOsNameMatches(OS_NAME_WINDOWS_PREFIX + " 11");

  1828.     /**
  1829.      * The constant {@code true} if this is z/OS.
  1830.      * <p>
  1831.      * The result depends on the value of the {@link #OS_NAME} constant.
  1832.      * </p>
  1833.      * <p>
  1834.      * The field will return {@code false} if {@link #OS_NAME} is {@code null}.
  1835.      * </p>
  1836.      * <p>
  1837.      * This value is initialized when the class is loaded.
  1838.      * </p>
  1839.      *
  1840.      * @since 3.5
  1841.      */
  1842.     // Values on a z/OS system I tested (Gary Gregory - 2016-03-12)
  1843.     // os.arch = s390x
  1844.     // os.encoding = ISO8859_1
  1845.     // os.name = z/OS
  1846.     // os.version = 02.02.00
  1847.     public static final boolean IS_OS_ZOS = getOsNameMatches("z/OS");

  1848.     /**
  1849.      * The System property key for the user home directory.
  1850.      */
  1851.     public static final String USER_HOME_KEY = "user.home";

  1852.     /**
  1853.      * The System property key for the user name.
  1854.      *
  1855.      * @deprecated Use {@link SystemProperties#USER_NAME}.
  1856.      */
  1857.     @Deprecated
  1858.     public static final String USER_NAME_KEY = "user.name";

  1859.     /**
  1860.      * The System property key for the user directory.
  1861.      *
  1862.      * @deprecated Use {@link SystemProperties#USER_DIR}.
  1863.      */
  1864.     @Deprecated
  1865.     public static final String USER_DIR_KEY = "user.dir";

  1866.     /**
  1867.      * The System property key for the Java IO temporary directory.
  1868.      *
  1869.      * @deprecated Use {@link SystemProperties#JAVA_IO_TMPDIR}.
  1870.      */
  1871.     @Deprecated
  1872.     public static final String JAVA_IO_TMPDIR_KEY = "java.io.tmpdir";

  1873.     /**
  1874.      * The System property key for the Java home directory.
  1875.      *
  1876.      * @deprecated Use {@link SystemProperties#JAVA_HOME}.
  1877.      */
  1878.     @Deprecated
  1879.     public static final String JAVA_HOME_KEY = "java.home";

  1880.     /**
  1881.      * A constant for the System Property {@code awt.toolkit}.
  1882.      *
  1883.      * <p>
  1884.      * Holds a class name, on Windows XP this is {@code sun.awt.windows.WToolkit}.
  1885.      * </p>
  1886.      * <p>
  1887.      * <strong>On platforms without a GUI, this value is {@code null}.</strong>
  1888.      * </p>
  1889.      * <p>
  1890.      * Defaults to {@code null} if the runtime does not have security access to read this property or the property does not exist.
  1891.      * </p>
  1892.      * <p>
  1893.      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or {@link System#setProperties(java.util.Properties)} is
  1894.      * called after this class is loaded, the value will be out of sync with that System property.
  1895.      * </p>
  1896.      *
  1897.      * @since 2.1
  1898.      * @see SystemProperties#getAwtToolkit()
  1899.      */
  1900.     public static final String AWT_TOOLKIT = SystemProperties.getAwtToolkit();

  1901.     /**
  1902.      * Gets an environment variable, defaulting to {@code defaultValue} if the variable cannot be read.
  1903.      *
  1904.      * <p>
  1905.      * If a {@link SecurityException} is caught, the return value is {@code defaultValue} and a message is written to {@code System.err}.
  1906.      * </p>
  1907.      *
  1908.      * @param name         the environment variable name.
  1909.      * @param defaultValue the default value.
  1910.      * @return the environment variable value or {@code defaultValue} if a security problem occurs.
  1911.      * @since 3.8
  1912.      */
  1913.     public static String getEnvironmentVariable(final String name, final String defaultValue) {
  1914.         try {
  1915.             final String value = System.getenv(name);
  1916.             return value == null ? defaultValue : value;
  1917.         } catch (final SecurityException ex) {
  1918.             // we are not allowed to look at this property
  1919.             // System.err.println("Caught a SecurityException reading the environment variable '" + name + "'.");
  1920.             return defaultValue;
  1921.         }
  1922.     }

  1923.     /**
  1924.      * Gets the host name from an environment variable ({@code COMPUTERNAME} on Windows, {@code HOSTNAME} elsewhere).
  1925.      *
  1926.      * <p>
  1927.      * If you want to know what the network stack says is the host name, you should use {@code InetAddress.getLocalHost().getHostName()}.
  1928.      * </p>
  1929.      *
  1930.      * @return the host name. Will be {@code null} if the environment variable is not defined.
  1931.      * @since 3.6
  1932.      */
  1933.     public static String getHostName() {
  1934.         return IS_OS_WINDOWS ? System.getenv("COMPUTERNAME") : System.getenv("HOSTNAME");
  1935.     }

  1936.     /**
  1937.      * Gets the current Java home directory as a {@link File}.
  1938.      *
  1939.      * @return a directory.
  1940.      * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
  1941.      * @see SystemProperties#getJavaHome()
  1942.      * @since 2.1
  1943.      */
  1944.     public static File getJavaHome() {
  1945.         return new File(SystemProperties.getJavaHome());
  1946.     }

  1947.     /**
  1948.      * Gets the current Java home directory as a {@link File}.
  1949.      *
  1950.      * @return a directory.
  1951.      * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
  1952.      * @see SystemProperties#getJavaHome()
  1953.      * @since 3.18.0
  1954.      */
  1955.     public static Path getJavaHomePath() {
  1956.         return Paths.get(SystemProperties.getJavaHome());
  1957.     }

  1958.     /**
  1959.      * Gets the current Java IO temporary directory as a {@link File}.
  1960.      *
  1961.      * @return a directory.
  1962.      * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
  1963.      * @see SystemProperties#getJavaIoTmpdir()
  1964.      * @since 2.1
  1965.      */
  1966.     public static File getJavaIoTmpDir() {
  1967.         return new File(SystemProperties.getJavaIoTmpdir());
  1968.     }

  1969.     /**
  1970.      * Gets the current Java IO temporary directory as a {@link Path}.
  1971.      *
  1972.      * @return a directory.
  1973.      * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
  1974.      * @see SystemProperties#getJavaIoTmpdir()
  1975.      * @since 3.18.0
  1976.      */
  1977.     public static Path getJavaIoTmpDirPath() {
  1978.         return Paths.get(SystemProperties.getJavaIoTmpdir());
  1979.     }

  1980.     /**
  1981.      * Tests if the Java version matches the version we are running.
  1982.      * <p>
  1983.      * The result depends on the value of the {@link #JAVA_SPECIFICATION_VERSION} constant.
  1984.      * </p>
  1985.      *
  1986.      * @param versionPrefix the prefix for the Java version.
  1987.      * @return true if matches, or false if not or can't determine.
  1988.      */
  1989.     private static boolean getJavaVersionMatches(final String versionPrefix) {
  1990.         return isJavaVersionMatch(JAVA_SPECIFICATION_VERSION, versionPrefix);
  1991.     }

  1992.     /**
  1993.      * Tests if the operating system matches the given name prefix and version prefix.
  1994.      * <p>
  1995.      * The result depends on the value of the {@link #OS_NAME} and {@link #OS_VERSION} constants.
  1996.      * </p>
  1997.      * <p>
  1998.      * The method returns {@code false} if {@link #OS_NAME} or {@link #OS_VERSION} is {@code null}.
  1999.      * </p>
  2000.      *
  2001.      * @param osNamePrefix    the prefix for the OS name.
  2002.      * @param osVersionPrefix the prefix for the version.
  2003.      * @return true if matches, or false if not or can't determine.
  2004.      */
  2005.     private static boolean getOsMatches(final String osNamePrefix, final String osVersionPrefix) {
  2006.         return isOsMatch(OS_NAME, OS_VERSION, osNamePrefix, osVersionPrefix);
  2007.     }

  2008.     /**
  2009.      * Tests if the operating system matches the given string with a case-insensitive comparison.
  2010.      * <p>
  2011.      * The result depends on the value of the {@link #OS_NAME} constant.
  2012.      * </p>
  2013.      * <p>
  2014.      * The method returns {@code false} if {@link #OS_NAME} is {@code null}.
  2015.      * </p>
  2016.      *
  2017.      * @param osNamePrefix the prefix for the OS name.
  2018.      * @return true if matches, or false if not or can't determine.
  2019.      */
  2020.     private static boolean getOsNameMatches(final String osNamePrefix) {
  2021.         return isOsNameMatch(OS_NAME, osNamePrefix);
  2022.     }

  2023.     /**
  2024.      * Gets the current user directory as a {@link File}.
  2025.      * <p>
  2026.      * The result is based on the system property {@value SystemProperties#USER_DIR}.
  2027.      * </p>
  2028.      *
  2029.      * @return a directory.
  2030.      * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
  2031.      * @see SystemProperties#getUserDir()
  2032.      * @since 2.1
  2033.      */
  2034.     public static File getUserDir() {
  2035.         return new File(SystemProperties.getUserDir());
  2036.     }

  2037.     /**
  2038.      * Gets the current user directory as a {@link Path}.
  2039.      * <p>
  2040.      * The result is based on the system property {@value SystemProperties#USER_DIR}.
  2041.      * </p>
  2042.      *
  2043.      * @return a directory.
  2044.      * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
  2045.      * @see SystemProperties#getUserDir()
  2046.      * @since 3.18.0
  2047.      */
  2048.     public static Path getUserDirPath() {
  2049.         return Paths.get(SystemProperties.getUserDir());
  2050.     }

  2051.     /**
  2052.      * Gets the current user home directory as a {@link File}.
  2053.      * <p>
  2054.      * The result is based on the system property {@value SystemProperties#USER_HOME}.
  2055.      * </p>
  2056.      *
  2057.      * @return a directory.
  2058.      * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
  2059.      * @see SystemProperties#getUserHome()
  2060.      * @since 2.1
  2061.      */
  2062.     public static File getUserHome() {
  2063.         return new File(SystemProperties.getUserHome());
  2064.     }

  2065.     /**
  2066.      * Gets the current user home directory as a {@link Path}.
  2067.      * <p>
  2068.      * The result is based on the system property {@value SystemProperties#USER_HOME}.
  2069.      * </p>
  2070.      *
  2071.      * @return a directory.
  2072.      * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
  2073.      * @see SystemProperties#getUserHome()
  2074.      * @since 3.18.0
  2075.      */
  2076.     public static Path getUserHomePath() {
  2077.         return Paths.get(SystemProperties.getUserHome());
  2078.     }

  2079.     /**
  2080.      * Gets the current user name.
  2081.      * <p>
  2082.      * The result is based on the system property {@value SystemProperties#USER_NAME}.
  2083.      * </p>
  2084.      *
  2085.      * @return a name.
  2086.      * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
  2087.      * @see SystemProperties#getUserName()
  2088.      * @since 3.10
  2089.      * @deprecated Use {@link SystemProperties#getUserName()}.
  2090.      */
  2091.     @Deprecated
  2092.     public static String getUserName() {
  2093.         return SystemProperties.getUserName();
  2094.     }

  2095.     /**
  2096.      * Gets the user name.
  2097.      * <p>
  2098.      * The result is based on the system property {@value SystemProperties#USER_NAME}.
  2099.      * </p>
  2100.      *
  2101.      * @param defaultValue A default value.
  2102.      * @return a name.
  2103.      * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow access to the specified system property.
  2104.      * @see SystemProperties#getUserName()
  2105.      * @since 3.10
  2106.      * @deprecated Use {@link SystemProperties#getUserName(String)}.
  2107.      */
  2108.     @Deprecated
  2109.     public static String getUserName(final String defaultValue) {
  2110.         return SystemProperties.getUserName(defaultValue);
  2111.     }

  2112.     /**
  2113.      * Tests whether the {@link #JAVA_AWT_HEADLESS} value is {@code true}.
  2114.      * <p>
  2115.      * The result is based on the system property {@value SystemProperties#JAVA_AWT_HEADLESS}.
  2116.      * </p>
  2117.      *
  2118.      * @return {@code true} if {@code JAVA_AWT_HEADLESS} is {@code "true"}, {@code false} otherwise.
  2119.      * @see #JAVA_AWT_HEADLESS
  2120.      * @since 2.1
  2121.      * @since Java 1.4
  2122.      */
  2123.     public static boolean isJavaAwtHeadless() {
  2124.         return Boolean.TRUE.toString().equals(JAVA_AWT_HEADLESS);
  2125.     }

  2126.     /**
  2127.      * Tests whether the Java version at least the requested version.
  2128.      * <p>
  2129.      * The result is based on the system property saved in {@link #JAVA_SPECIFICATION_VERSION}.
  2130.      * </p>
  2131.      *
  2132.      * @param requiredVersion the required version, for example 1.31f.
  2133.      * @return {@code true} if the actual version is equal or greater than the required version.
  2134.      */
  2135.     public static boolean isJavaVersionAtLeast(final JavaVersion requiredVersion) {
  2136.         return JAVA_SPECIFICATION_VERSION_AS_ENUM != null && JAVA_SPECIFICATION_VERSION_AS_ENUM.atLeast(requiredVersion);
  2137.     }

  2138.     /**
  2139.      * Tests whether the Java version at most the requested version.
  2140.      * <p>
  2141.      * The result is based on the system property saved in {@link #JAVA_SPECIFICATION_VERSION}.
  2142.      * </p>
  2143.      *
  2144.      * @param requiredVersion the required version, for example 1.31f.
  2145.      * @return {@code true} if the actual version is equal or less than the required version.
  2146.      * @since 3.9
  2147.      */
  2148.     public static boolean isJavaVersionAtMost(final JavaVersion requiredVersion) {
  2149.         return JAVA_SPECIFICATION_VERSION_AS_ENUM != null && JAVA_SPECIFICATION_VERSION_AS_ENUM.atMost(requiredVersion);
  2150.     }

  2151.     /**
  2152.      * Tests whether the Java version matches.
  2153.      *
  2154.      * <p>
  2155.      * This method is package private instead of private to support unit test invocation.
  2156.      * </p>
  2157.      *
  2158.      * @param version       the actual Java version.
  2159.      * @param versionPrefix the prefix for the expected Java version.
  2160.      * @return true if matches, or false if not or can't determine.
  2161.      */
  2162.     static boolean isJavaVersionMatch(final String version, final String versionPrefix) {
  2163.         if (version == null) {
  2164.             return false;
  2165.         }
  2166.         return version.startsWith(versionPrefix);
  2167.     }

  2168.     /**
  2169.      * Tests whether the operating system matches.
  2170.      * <p>
  2171.      * This method is package private instead of private to support unit test invocation.
  2172.      * </p>
  2173.      *
  2174.      * @param osName          the actual OS name.
  2175.      * @param osVersion       the actual OS version.
  2176.      * @param osNamePrefix    the prefix for the expected OS name.
  2177.      * @param osVersionPrefix the prefix for the expected OS version.
  2178.      * @return true if matches, or false if not or can't determine.
  2179.      */
  2180.     static boolean isOsMatch(final String osName, final String osVersion, final String osNamePrefix, final String osVersionPrefix) {
  2181.         if (osName == null || osVersion == null) {
  2182.             return false;
  2183.         }
  2184.         return isOsNameMatch(osName, osNamePrefix) && isOsVersionMatch(osVersion, osVersionPrefix);
  2185.     }

  2186.     /**
  2187.      * Tests whether the operating system matches with a case-insensitive comparison.
  2188.      * <p>
  2189.      * This method is package private instead of private to support unit test invocation.
  2190.      * </p>
  2191.      *
  2192.      * @param osName       the actual OS name.
  2193.      * @param osNamePrefix the prefix for the expected OS name.
  2194.      * @return true for a case-insensitive match, or false if not.
  2195.      */
  2196.     static boolean isOsNameMatch(final String osName, final String osNamePrefix) {
  2197.         if (osName == null) {
  2198.             return false;
  2199.         }
  2200.         return Strings.CI.startsWith(osName, osNamePrefix);
  2201.     }

  2202.     /**
  2203.      * Tests whether the operating system version matches.
  2204.      * <p>
  2205.      * This method is package private instead of private to support unit test invocation.
  2206.      * </p>
  2207.      *
  2208.      * @param osVersion       the actual OS version.
  2209.      * @param osVersionPrefix the prefix for the expected OS version.
  2210.      * @return true if matches, or false if not or can't determine.
  2211.      */
  2212.     static boolean isOsVersionMatch(final String osVersion, final String osVersionPrefix) {
  2213.         if (StringUtils.isEmpty(osVersion)) {
  2214.             return false;
  2215.         }
  2216.         // Compare parts of the version string instead of using String.startsWith(String) because otherwise
  2217.         // osVersionPrefix 10.1 would also match osVersion 10.10
  2218.         final String[] versionPrefixParts = JavaVersion.split(osVersionPrefix);
  2219.         final String[] versionParts = JavaVersion.split(osVersion);
  2220.         for (int i = 0; i < Math.min(versionPrefixParts.length, versionParts.length); i++) {
  2221.             if (!versionPrefixParts[i].equals(versionParts[i])) {
  2222.                 return false;
  2223.             }
  2224.         }
  2225.         return true;
  2226.     }

  2227.     /**
  2228.      * SystemUtils instances shouldn't be constructed in standard programming. Instead, elements should be accessed directly, for example
  2229.      * {@code SystemUtils.FILE_SEPARATOR}.
  2230.      *
  2231.      * <p>
  2232.      * This constructor is public to permit tools that require a JavaBean instance to operate.
  2233.      * </p>
  2234.      */
  2235.     public SystemUtils() {
  2236.     }

  2237. }