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.
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.
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.
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.