Skip to content

Global java vm arguments

When you start a Java virtual machine you can specify various vm arguments. Some alter the memory management, some the garbage collection and some are system properties.

But you can also specify global vm arguments that are picked up by every virtual machine that starts within an environment context.

These global options are specified using the _JAVA_OPTIONS environment variable.

_JAVA_OPTIONS=-Xmx1024m

When you start a JVM while the _JAVA_OPTIONS environment variable is set you will see something like

Picked up _JAVA_OPTIONS: -Xm1024m

on the command line. The JVM tells you that it has found global java options and picked it up.

Useful _JAVA_OPTIONS use cases

  • Certificate management
    In a lot of development environments self-signed SSL certificates are used. It’s really annoying if your java applications or integration tests must establish SSL connections and you get SSL handshake exceptions,  because the JVM can’t find a valid certification path. In this case I usually create a truststore on my computer and just add the follwing _JAVA_OPTIONS to my environment variables.

    _JAVA_OPTION=-Djavax.net.ssl.trustStore=C:\dev\java\global_truststore

    PS: trust stores can be easily managed using Keystore Explorer.

  • OutOfMemory analysis
    Often when an OutOfMemory errors you realize that you forgot to enable the heap dump on out of memory -XX:+HeapDumpOnOutOfMemoryError. So I usually add that jvm argument to my _JAVA_OPTION.

    _JAVA_OPTIONS=-XX:+HeapDumpOnOutOfMemoryError

    Heap dumps can be analysed using a Memory Analyser. Further information about heap dump settings can be found at B.1 HotSpot VM Command-Line Options.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

 

GDPR Cookie Consent with Real Cookie Banner