Object Os

  • All Implemented Interfaces:

    
    public class Os
    
                        

    Operating-System-specific utility functions.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final String fixupUserHomeProperty() Check if the "user.home" property is set to a sane value and otherwise set it to the value of an (OS-specific) environment variable for the user home directory, and return that value.
      final File getPathFromEnvironment(String executable) Return the full path to the given executable file if it is in the system's PATH environment, or null otherwise.
      final File resolveWindowsExecutable(File executable) Resolve the Windows executable to its full name including the optional extension.
      final String getName() The operating system name.
      final Boolean isLinux() Whether the operating system is Linux or not.
      final Boolean isMac() Whether the operating system is macOS or not.
      final Boolean isWindows() Whether the operating system is Windows or not.
      final SortedMap<String, String> getEnv() The currently set environment variables.
      final File getUserHomeDirectory() The current user's home directory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • fixupUserHomeProperty

         final String fixupUserHomeProperty()

        Check if the "user.home" property is set to a sane value and otherwise set it to the value of an (OS-specific) environment variable for the user home directory, and return that value. This works around the issue that esp. in certain Docker scenarios "user.home" is set to "?", see https://bugs.openjdk.java.net/browse/JDK-8193433 for some background information.

      • getPathFromEnvironment

         final File getPathFromEnvironment(String executable)

        Return the full path to the given executable file if it is in the system's PATH environment, or null otherwise.

      • isLinux

         final Boolean isLinux()

        Whether the operating system is Linux or not.

      • isMac

         final Boolean isMac()

        Whether the operating system is macOS or not.

      • isWindows

         final Boolean isWindows()

        Whether the operating system is Windows or not.