Object Os
-
- All Implemented Interfaces:
public class OsOperating-System-specific utility functions.
-
-
Field Summary
Fields Modifier and Type Field Description private final <Error class: unknown class>nameprivate final BooleanisLinuxprivate final BooleanisMacprivate final BooleanisWindowsprivate final <Error class: unknown class>envprivate final <Error class: unknown class>userHomeDirectorypublic final static OsINSTANCE
-
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 FileresolveExecutable(File executable)Resolve the executable to its full name including any optional Windows extension. final <Error class: unknown class>getName()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 <Error class: unknown class>getEnv()The currently set environment variables. final <Error class: unknown class>getUserHomeDirectory()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.
-
resolveExecutable
final File resolveExecutable(File executable)
Resolve the executable to its full name including any optional Windows extension.
-
getName
final <Error class: unknown class> getName()
The operating system name.
-
getEnv
final <Error class: unknown class> getEnv()
The currently set environment variables. Keys are case-insensitive on Windows.
-
getUserHomeDirectory
final <Error class: unknown class> getUserHomeDirectory()
The current user's home directory.
-
-
-
-