Skip to content

Reference: Java Virtual Machineλ︎

Understand the configuration options for the Java Virtual machine (JVM) which Clojure is hosted upon.

Overview of tools for monitoring and profiling Clojure applications running on the JVM, to ensure effective running of Clojure applications in production.

JDK_JAVA_OPTIONS Environment Variable

JDK_JAVA_OPTIONS is the official Environment Variable for setting options when calling java, javac and other Java commands to start running a Java Virtual Machine (Java version 9 onward).

Display resources available to the JVMλ︎

-XshowSettings:system displays the resources the JVM believes it has access too when running any Java command and is a very simple diagnostic tool to start with.

See the environment resources available to the JVM without running a Clojure or Java application:

java -XshowSettings:system -version

Java Virtual Machine - show system settings without running an application

Include -XshowSettings:system when running any Java command to provide simple diagnostics, e.g. when running a Clojure Uberjar

java -XshowSettings:system -jar practicalli-service.jar

Print resources in Container systems

-XshowSettings:system is especially useful for environments which may vary in resources available, such as containers (Docker, Kubernettes, etc.)

JVM option typesλ︎

-X - nonstandard VM options

-XX standard VM options

-XX options are not checked for validity, so are ignored if the VM does not recognize the option. Options can therefore be used across different VM versions without ensuring a particular level of the VM.

-D a system property for the application running on the JVM using a name=value

Java Modulesλ︎

Java 9 introduced modules to move features out of JVM itself and include them as optional modules.

Before CLJS-2377 issue was resolved, ClojureScript (2017) depended on java.xml.bind.DataTypeConverter. java.xml.bind package was deprecated in Java 9 and moved to a non-default module.

At that time, compiling a ClojureScript project without adding the java.xml.bind module would return the error:

<Exception details>
...
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter

clojure J--add-modules "java.xml.bind" command line option will include the module

:jvm-opts ["--add-modules" "java.xml.bind"] added to Clojure CLI deps.edn or Leiningen project.clj file will include the module.

-Djdk.launcher.addmods=java.xml.bind added to the JAVA_TOOL_OPTIONS environment variable (jdk.launcher.addmods --add-modules doesn’t work in JAVA_TOOL_OPTIONS)

Unified Logging sub-systemλ︎

-Xlog - JEP 158

Referencesλ︎