public final class SystemUtils extends Object
Constants have been taken from System.getProperties()
with the
following exclusions:
System Property | Direct Representation | Representation for technical usage |
---|---|---|
file.separator
| File.separatorChar
| |
path.separator
| File.pathSeparatorChar
| |
line.separator
| System.lineSeparator()
| Strings.NEW_LINE
|
Charset
| Charset.defaultCharset()
| Strings.DEFAULT_CHARSET
|
Locale
| Locale.getDefault()
| Strings.DEFAULT_LOCALE
|
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_FILE_NAME_SEPARATOR
Constant
"/" as system-independent name-separator character for use
in paths, represented as a string for convenience. |
static char |
DEFAULT_FILE_NAME_SEPARATOR_CHAR
Constant
'/' as system-independent name-separator character for use
in paths. |
static String |
FILE_EXTENSION_SEPARATOR
Constant
"." as separator between file name and file extension,
represented as a string for convenience. |
static char |
FILE_EXTENSION_SEPARATOR_CHAR
Constant
'.' as separator between file name and file extension. |
static String |
JAVA_CLASS_PATH
Java class path
|
static String |
JAVA_CLASS_VERSION
Java class format version number
|
static String |
JAVA_COMPILER
Name of JIT compiler to use
|
static String |
JAVA_EXT_DIRS
Deprecated.
This property, and the mechanism which implements it, may be
removed in a future release.
|
static String |
JAVA_HOME
Java installation directory
|
static String |
JAVA_IO_TMPDIR
Default temporary file path
Better not rely on this in case
Files.createTempDirectory(Path, String, java.nio.file.attribute.FileAttribute...) |
static String |
JAVA_LIBRARY_PATH
List of paths to search when loading libraries
|
static String |
JAVA_SPECIFICATION_NAME
Java Runtime Environment specification name
|
static String |
JAVA_SPECIFICATION_VENDOR
Java Runtime Environment specification vendor
|
static String |
JAVA_SPECIFICATION_VERSION
Java Runtime Environment specification version
|
static String |
JAVA_VENDOR
Java Runtime Environment vendor
|
static String |
JAVA_VENDOR_URL
Java vendor URL
|
static String |
JAVA_VERSION
Java Runtime Environment version
|
static String |
JAVA_VM_NAME
Java Virtual Machine implementation name
|
static String |
JAVA_VM_SPECIFICATION_NAME
Java Virtual Machine specification name
|
static String |
JAVA_VM_SPECIFICATION_VENDOR
Java Virtual Machine specification vendor
|
static String |
JAVA_VM_SPECIFICATION_VERSION
Java Virtual Machine specification version
|
static String |
JAVA_VM_VENDOR
Java Virtual Machine implementation vendor
|
static String |
JAVA_VM_VERSION
Java Virtual Machine implementation version
|
static String |
OS_ARCH
Operating system architecture
|
static String |
OS_NAME
Operating system name
|
static String |
OS_VERSION
Operating system version
|
static String |
USER_DIR
User's current working directory
|
static String |
USER_HOME
User's home directory
Better not rely on this in case
getUserHome() is an appropriate
alternative. |
static String |
USER_NAME
User's account name
Better not rely on this in case
getUserName() is an appropriate
alternative. |
Modifier and Type | Method and Description |
---|---|
static Path |
getJavaExecutable()
Determines the system specific path to the current JVMs binary executable.
|
static Path |
getUserHome()
User's home directory
|
static String |
getUserName()
User's account name
|
static boolean |
isWindows()
Validates the system property
os.name and returns true on Windows OS. |
public static final char DEFAULT_FILE_NAME_SEPARATOR_CHAR
'/'
as system-independent name-separator character for use
in paths. Remember to use File.separatorChar
when working
with system-dependent paths!
Why shouldn't I use '/'
directly?
Using '/'
is bad practice, as it holds implementation specific
information.
public static final String DEFAULT_FILE_NAME_SEPARATOR
"/"
as system-independent name-separator character for use
in paths, represented as a string for convenience. This string contains a
single character, namely DEFAULT_FILE_NAME_SEPARATOR_CHAR
. Remember
to use File.separator
when working with system-dependent
paths!
Why shouldn't I use "/"
directly?
Using "/"
is bad practice, as it holds implementation specific
information.
public static final char FILE_EXTENSION_SEPARATOR_CHAR
'.'
as separator between file name and file extension.
Why shouldn't I use '.'
directly?
Using '.'
is bad practice, as it holds implementation specific
information.
public static final String FILE_EXTENSION_SEPARATOR
"."
as separator between file name and file extension,
represented as a string for convenience. This string contains a single
character, namely FILE_EXTENSION_SEPARATOR_CHAR
.
Why shouldn't I use "."
directly?
Using "."
is bad practice, as it holds implementation specific
information.
public static final String JAVA_VERSION
public static final String JAVA_VENDOR
public static final String JAVA_VENDOR_URL
public static final String JAVA_HOME
public static final String JAVA_VM_SPECIFICATION_VERSION
public static final String JAVA_VM_SPECIFICATION_VENDOR
public static final String JAVA_VM_SPECIFICATION_NAME
public static final String JAVA_VM_VERSION
public static final String JAVA_VM_VENDOR
public static final String JAVA_VM_NAME
public static final String JAVA_SPECIFICATION_VERSION
public static final String JAVA_SPECIFICATION_VENDOR
public static final String JAVA_SPECIFICATION_NAME
public static final String JAVA_CLASS_VERSION
public static final String JAVA_CLASS_PATH
public static final String JAVA_LIBRARY_PATH
public static final String JAVA_IO_TMPDIR
Better not rely on this in case
Files.createTempDirectory(Path, String, java.nio.file.attribute.FileAttribute...)
or
Files.createTempFile(Path, String, String, java.nio.file.attribute.FileAttribute...)
are appropriate alternatives.
public static final String JAVA_COMPILER
@Deprecated public static final String JAVA_EXT_DIRS
public static final String OS_NAME
public static final String OS_ARCH
public static final String OS_VERSION
public static final String USER_NAME
Better not rely on this in case getUserName()
is an appropriate
alternative.
public static final String USER_HOME
Better not rely on this in case getUserHome()
is an appropriate
alternative.
public static final String USER_DIR
public static Path getJavaExecutable()
public static String getUserName()
public static Path getUserHome()
public static boolean isWindows()
os.name
and returns true on Windows OS.
Usage of feature detection is highly preferred. Use with caution!
true
when running on Windows, otherwise false
Copyright © 2025. All rights reserved.