Object Os
-
- All Implemented Interfaces:
public class OsOperating-System-specific utility functions.
-
-
Method Summary
Modifier and Type Method Description final StringfixupUserHomeProperty()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 FilegetPathFromEnvironment(String executable)Return the full path to the given executable file if it is in the system's PATH environment, or null otherwise. final FileresolveWindowsExecutable(File executable)Resolve the Windows executable to its full name including the optional extension. final StringgetName()The operating system name. final BooleanisLinux()Whether the operating system is Linux or not. final BooleanisMac()Whether the operating system is macOS or not. final BooleanisWindows()Whether the operating system is Windows or not. final SortedMap<String, String>getEnv()The currently set environment variables. final FilegetUserHomeDirectory()The current user's home directory. -
-
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.
-
resolveWindowsExecutable
final File resolveWindowsExecutable(File executable)
Resolve the Windows executable to its full name including the optional extension.
-
getEnv
final SortedMap<String, String> getEnv()
The currently set environment variables. Keys are case-insensitive on Windows.
-
getUserHomeDirectory
final File getUserHomeDirectory()
The current user's home directory.
-
-
-
-