Class SystemUtils

java.lang.Object
org.apache.maven.plugins.javadoc.SystemUtils

class SystemUtils extends Object
Contains several OS-specific methods from Commons-Lang3's SystemUtils. We don't want to use that class because it uses enums for Java versions, which implies that with every new Java version a new commons-lang3 is required.
Since:
3.0.1
  • Field Details

    • OS_NAME

      public static final String OS_NAME

      The os.name System Property. Operating system name.

      Defaults to null if the runtime does not have security access to read this property or the property does not exist.

      This value is initialized when the class is loaded. If System.setProperty(String,String) or System.setProperties(java.util.Properties) is called after this class is loaded, the value will be out of sync with that System property.

      Since:
      Java 1.1
    • OS_NAME_WINDOWS_PREFIX

      private static final String OS_NAME_WINDOWS_PREFIX
      The prefix String for all Windows OS.
      See Also:
    • IS_OS_AIX

      public static final boolean IS_OS_AIX

      Is true if this is AIX.

      The field will return false if OS_NAME is null.

    • IS_OS_MAC_OSX

      public static final boolean IS_OS_MAC_OSX

      Is true if this is Mac.

      The field will return false if OS_NAME is null.

    • IS_OS_WINDOWS

      public static final boolean IS_OS_WINDOWS

      Is true if this is Windows.

      The field will return false if OS_NAME is null.

    • JAVA_HOME_KEY

      private static final String JAVA_HOME_KEY
      The System property key for the Java home directory.
      See Also:
    • LINE_SEPARATOR

      public static final String LINE_SEPARATOR

      The line.separator System Property. Line separator ("\n" on UNIX).

      Defaults to null if the runtime does not have security access to read this property or the property does not exist.

      This value is initialized when the class is loaded. If System.setProperty(String,String) or System.setProperties(java.util.Properties) is called after this class is loaded, the value will be out of sync with that System property.

      Since:
      Java 1.1
  • Constructor Details

    • SystemUtils

      SystemUtils()
  • Method Details

    • getOSMatchesName

      private static boolean getOSMatchesName(String osNamePrefix)
      Decides if the operating system matches.
      Parameters:
      osNamePrefix - the prefix for the os name
      Returns:
      true if matches, or false if not or can't determine
    • isOSNameMatch

      static boolean isOSNameMatch(String osName, String osNamePrefix)
      Decides if the operating system matches.

      This method is package private instead of private to support unit test invocation.

      Parameters:
      osName - the actual OS name
      osNamePrefix - the prefix for the expected OS name
      Returns:
      true if matches, or false if not or can't determine
    • getJavaHome

      public static File getJavaHome()

      Gets the Java home directory as a File.

      Returns:
      a directory
      Throws:
      SecurityException - if a security manager exists and its checkPropertyAccess method doesn't allow access to the specified system property.
      Since:
      2.1
      See Also:
    • getSystemProperty

      private static String getSystemProperty(String property)

      Gets a System property, defaulting to null if the property cannot be read.

      If a SecurityException is caught, the return value is null and a message is written to System.err.

      Parameters:
      property - the system property name
      Returns:
      the system property value or null if a security problem occurs