Jvm

object Jvm

Object with utilities to gather information about the running JVM.

Properties

Link copied to clipboard
val charset: Charset

Default character set.

Link copied to clipboard
val console: Console

JVM Console, if the program don't have a console (i.e.: input or output redirected), an exception is thrown.

Link copied to clipboard
val cpuCount: Int

Number of processors available to the Java virtual machine.

Link copied to clipboard
val hostName: String

The host name of the machine running this program.

Link copied to clipboard
val ip: String

The IP address of the machine running this program.

Link copied to clipboard
val isConsole: Boolean

True if the program has a console (terminal, TTY, PTY...), false if I/O is piped.

Link copied to clipboard
val locale: Locale

Default locale for this instance of the Java Virtual Machine.

Link copied to clipboard
val localeCode: String

User locale consist of 2-letter language code, 2-letter country code and file encoding.

Link copied to clipboard
val name: String

Name of the JVM running this program. For example: OpenJDK 64-Bit Server VM.

Link copied to clipboard
val os: String

Operating system name ('os.name' property). If null throws an exception.

Link copied to clipboard

Operating system type.

Link copied to clipboard
val runtime: Runtime

Current JVM runtime.

Link copied to clipboard
val timeZone: TimeZone

Default timezone.

Link copied to clipboard
val version: String

Java version aka language level. For example: 11

Link copied to clipboard
val zoneId: ZoneId

Default zone ID.

Functions

Link copied to clipboard
fun loadSystemSettings(settings: Map<String, String>)

Add a map to system properties, overriding entries if already set.

Link copied to clipboard
fun systemFlag(name: String): Boolean

Retrieve a flag (boolean parameter) by name by looking in OS environment variables first and in the JVM system properties if not found.

Link copied to clipboard
inline fun <T : Any> systemSetting(name: String): T
inline fun <T : Any> systemSetting(name: String, defaultValue: T): T
fun <T : Any> systemSetting(type: KClass<T>, name: String): T
fun <T : Any> systemSetting(type: KClass<T>, name: String, defaultValue: T): T
Link copied to clipboard
inline fun <T : Any> systemSettingOrNull(name: String): T?

Utility method for retrieving a system setting, check systemSettingOrNull for details.

fun <T : Any> systemSettingOrNull(type: KClass<T>, name: String): T?

Retrieve a setting by name by looking in OS environment variables first and in the JVM system properties if not found.

Link copied to clipboard
fun totalMemory(): String

Amount of memory in kilobytes available to the JVM.

Link copied to clipboard
fun usedMemory(): String

Amount of used memory in kilobytes.