Object Jvm
-
- All Implemented Interfaces:
public class JvmObject with utilities to gather information about the running JVM.
-
-
Field Summary
Fields Modifier and Type Field Description private final Stringosprivate final OsKindosKindprivate final Consoleconsoleprivate final BooleanisConsoleprivate final Runtimeruntimeprivate final TimeZonetimeZoneprivate final ZoneIdzoneIdprivate final Charsetcharsetprivate final Localelocaleprivate final StringhostNameprivate final Stringipprivate final Stringnameprivate final Stringversionprivate final IntegercpuCountprivate final StringlocaleCodepublic final static JvmINSTANCE
-
Method Summary
Modifier and Type Method Description final StringtotalMemory()Amount of memory in kilobytes available to the JVM. final StringusedMemory()Amount of used memory in kilobytes. final UnitloadSystemSettings(Map<String, String> settings, Boolean overwrite)final <T extends Any> TsystemSettingOrNull(KClass<T> type, String name)Retrieve a setting by name by looking in the JVM system properties first and in OS environment variables if not found. final <T extends Any> TsystemSettingOrNull(String name)Utility method for retrieving a system setting, check systemSettingOrNull for details. final <T extends Any> TsystemSetting(KClass<T> type, String name)final <T extends Any> TsystemSetting(String name)final BooleansystemFlag(String name)Retrieve a flag (boolean parameter) by name by looking in the JVM system properties first and in OS environment variables if not found. final StringgetOs()Operating system name ('os.name' property). final OsKindgetOsKind()Operating system type. final ConsolegetConsole()JVM Console, if the program don't have a console (i.e.: input or output redirected), an exception is thrown. final BooleanisConsole()True if the program has a console (terminal, TTY, PTY...), false if I/O is piped. final RuntimegetRuntime()Current JVM runtime. final TimeZonegetTimeZone()Default timezone. final ZoneIdgetZoneId()Default zone ID. final CharsetgetCharset()Default character set. final LocalegetLocale()Default locale for this instance of the Java Virtual Machine. final StringgetHostName()The host name of the machine running this program. final StringgetIp()The IP address of the machine running this program. final StringgetName()Name of the JVM running this program. final StringgetVersion()Java version aka language level. final IntegergetCpuCount()Number of processors available to the Java virtual machine. final StringgetLocaleCode()User locale consist of 2-letter language code, 2-letter country code and file encoding. -
-
Method Detail
-
totalMemory
final String totalMemory()
Amount of memory in kilobytes available to the JVM.
- Returns:
Total amount of memory in kilobytes.
-
usedMemory
final String usedMemory()
Amount of used memory in kilobytes.
- Returns:
Used memory in kilobytes.
-
loadSystemSettings
final Unit loadSystemSettings(Map<String, String> settings, Boolean overwrite)
-
systemSettingOrNull
final <T extends Any> T systemSettingOrNull(KClass<T> type, String name)
Retrieve a setting by name by looking in the JVM system properties first and in OS environment variables if not found.
- Parameters:
type- Type of the requested parameter.name- Name of the searched parameter, can not be blank.- Returns:
Value of the searched parameter in the requested type,
nullif the parameter is not found on the JVM system properties and in OS environment variables.
-
systemSettingOrNull
final <T extends Any> T systemSettingOrNull(String name)
Utility method for retrieving a system setting, check systemSettingOrNull for details.
- Parameters:
name- Name of the searched parameter, can not be blank.- Returns:
Value of the searched parameter in the requested type,
nullif the parameter is not found on the JVM system properties and in OS environment variables.
-
systemSetting
final <T extends Any> T systemSetting(KClass<T> type, String name)
-
systemSetting
final <T extends Any> T systemSetting(String name)
-
systemFlag
final Boolean systemFlag(String name)
Retrieve a flag (boolean parameter) by name by looking in the JVM system properties first and in OS environment variables if not found.
- Parameters:
name- Name of the searched parameter, can not be blank.- Returns:
True if the parameter is found and its value is exactly 'true', false otherwise.
-
getOs
final String getOs()
Operating system name ('os.name' property). If
nullthrows an exception.
-
getConsole
final Console getConsole()
JVM Console, if the program don't have a console (i.e.: input or output redirected), an exception is thrown.
-
isConsole
final Boolean isConsole()
True if the program has a console (terminal, TTY, PTY...), false if I/O is piped.
-
getRuntime
final Runtime getRuntime()
Current JVM runtime.
-
getTimeZone
final TimeZone getTimeZone()
Default timezone.
-
getZoneId
final ZoneId getZoneId()
Default zone ID.
-
getCharset
final Charset getCharset()
Default character set.
-
getLocale
final Locale getLocale()
Default locale for this instance of the Java Virtual Machine.
-
getHostName
final String getHostName()
The host name of the machine running this program.
-
getIp
final String getIp()
The IP address of the machine running this program.
-
getName
final String getName()
Name of the JVM running this program. For example: OpenJDK 64-Bit Server VM.
-
getVersion
final String getVersion()
Java version aka language level. For example: 11
-
getCpuCount
final Integer getCpuCount()
Number of processors available to the Java virtual machine.
-
getLocaleCode
final String getLocaleCode()
User locale consist of 2-letter language code, 2-letter country code and file encoding.
-
-
-
-