You know how to set the variable in a shell, but for the record you can write:

export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on'

and all programs you start from this shell session after that will have the variable set.

If you want it to be set for every shell you start afterwards, add that line to ~/.profile as well. In that case it will apply to all future shells you start, but not any that are currently running.

.profile will generally work for the GUI as well, but that can be broken by system configuration and how you start things up. This is per-user configuration only.


If you want it set for every user all the time, you can add an assignment to /etc/environment. The format is a little different there: just KEY=VAL on separate lines, with no required quoting and none of anything else.

_JAVA_OPTIONS=-Dawt.useSystemAAFontSettings=on

This is parsed by the pam_env module. There is a per-user ~/.pam_environment file as well, which has the same effect for just the one user. These both require logging out and back in for the change to take effect. The variables will be set for every future login session, both at the console and in X.

Similarly, you can make a file in /etc/profile.d with an export statement in it and it will be loaded into every future session by any user. There will likely be some pre-existing files there to model it on, but just the export line above will be fine.


Alternatively, you can add the export statement in ~/.xinitrc (if you use startx), ~/.xsession, or ~/.xprofile. KDE also supports a directory ~/.kde/env that can contain as many shell files as you want, which contain export statements as above. I would probably prefer one of the other approaches.

Answer from Michael Homer on Stack Exchange
Top answer
1 of 1
12

You know how to set the variable in a shell, but for the record you can write:

export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on'

and all programs you start from this shell session after that will have the variable set.

If you want it to be set for every shell you start afterwards, add that line to ~/.profile as well. In that case it will apply to all future shells you start, but not any that are currently running.

.profile will generally work for the GUI as well, but that can be broken by system configuration and how you start things up. This is per-user configuration only.


If you want it set for every user all the time, you can add an assignment to /etc/environment. The format is a little different there: just KEY=VAL on separate lines, with no required quoting and none of anything else.

_JAVA_OPTIONS=-Dawt.useSystemAAFontSettings=on

This is parsed by the pam_env module. There is a per-user ~/.pam_environment file as well, which has the same effect for just the one user. These both require logging out and back in for the change to take effect. The variables will be set for every future login session, both at the console and in X.

Similarly, you can make a file in /etc/profile.d with an export statement in it and it will be loaded into every future session by any user. There will likely be some pre-existing files there to model it on, but just the export line above will be fine.


Alternatively, you can add the export statement in ~/.xinitrc (if you use startx), ~/.xsession, or ~/.xprofile. KDE also supports a directory ~/.kde/env that can contain as many shell files as you want, which contain export statements as above. I would probably prefer one of the other approaches.

🌐
Oracle
docs.oracle.com › cd › E37116_01 › install.111210 › e23737 › configuring_jvm.htm
7 Configuring the JVM, Java Options, and Database Cache
If you use the GUI installer, you can configure Java runtime settings as part of the install process. To configure Java runtime settings, click Change on the Runtime Options panel.
Discussions

How do I set Java's min and max heap size through environment variables? - Stack Overflow
I know that the heap sizes can be set when launching java, but I would like to have this adjusted through environment variables on my server. ... The accepted answer is out of date and does not apply anymore. Refer to @Gauthier's answer if you end up here ... Save this answer. ... Show activity on this post. You can't do it using environment variables directly. You need to use the set of "non standard" options ... More on stackoverflow.com
🌐 stackoverflow.com
java - Information about _JAVA_OPTIONS - Stack Overflow
Since JDK 9+ there's also JDK_JAVA_OPTIONS as the preferred replacement, see What is the difference between JDK_JAVA_OPTIONS and JAVA_TOOL_OPTIONS when using Java 11? ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 44 How to set a java ... More on stackoverflow.com
🌐 stackoverflow.com
java opts - how to set JAVA_OPTS for Tomcat in Windows? - Stack Overflow
SET JAVA_HOME=C:\Applications\java\java_8 SET PATH=%PATH%;C:\Applications\java\java_8\bin SET JAVA_OPTIONS=-d64 -Xms128g -Xmx128g More on stackoverflow.com
🌐 stackoverflow.com
java - Setting JAVA_OPTS in windows using command prompt - Stack Overflow
I am running the java program on windows server 2012, I want to set the JAVA_OPTS variable and use it, here is how I am doing it: Open a command prompt in the bin of jdk where it is installed ,and More on stackoverflow.com
🌐 stackoverflow.com
🌐
IBM
ibm.com › docs › en › sdk-java-technology › 8
Specifying Java options and system properties - IBM Documentation
January 22, 2026 - Create a file that contains the options, and specify that file on the command line or in the IBM_JAVA_OPTIONS environment variable by using the -Xoptionsfile parameter.
🌐
Liquibase
docs.liquibase.com › concepts › connections › java-opts-environment-variable.html
What are JAVA_OPTS environment variables?
You can set one property at a time, or set multiple properties separated by a whitespace character. For example, to set the changelog-lock-poll-rate property when using the update command, open the command line and pass arguments to JAVA_OPTS using the -Dproperty=value format.
Find elsewhere
🌐
Logi Analytics
devnet.logianalytics.com › hc › en-us › articles › 4406817686551-Setting-Java-Options
Setting Java Options – Logi Analytics
April 6, 2022 - The Performance Settings are strongly recommended for the Oracle JDK, whereas the JConsole and Tracing Settings are optional but recommended, at least during initial implementation. -server (JDK) -Xmx4096m (JDK) -XX:MaxPermSize=256m (JDK) -XX:-DisableExplicitGC (JDK) -XX:CompileThreshold=8000 (JDK) -Djava.awt.headless=true (JDK) -Djava.net.preferIPv4Stack=true (needed if sending email and using Java 1.7+) -d64 (JDK - for 64-bit JVMs only)
🌐
DUG Insight
help.dugeo.com › m › faq › l › 98932-how-do-i-edit-the-java-s-overriding-environment-variable
How do I edit the Java's overriding Environment Variable? | Frequently Asked Questions | DUG Insight User Manual
On the left panel, click Advanced system settings. This will open the Advanced tab in the System Properties window. In the Advanced tab in the System Properties window, click Environment Variables. This will open the Environment Variables window. In either the System variables or the User variables ...
🌐
Oracle
docs.oracle.com › cd › E22289_01 › html › 821-1274 › configuring-the-default-jvm-and-java-arguments.html
Configuring the Default JVM and Java Arguments - Oracle Fusion Middleware Installation Guide for Oracle Unified Directory
The directory server provides a means of configuring the Java Virtual Machine (JVM) and Java options for each command-line utility and for the directory server itself. The Java configuration is provided in a properties file, located at instance-dir/OUD/config/java.properties.
🌐
Sos-berlin
kb.sos-berlin.com › display › JS7 › JS7+-+How+To+-+Apply+Java+Options
JS7 - How To - Apply Java Options - Product Knowledge Base - JS7 JobScheduler
May 26, 2022 - Windows example to run the Agent instance start script with Java options · @rem Set Java options before running the Agent start script from the command line set JAVA_OPTIONS="-Xms128m -Xmx500m" .\agent.cmd start @rem Alternatively set Java options when running the Agent start script .\agent.cmd start --java-options="-Xms128m -Xmx500m" @rem For use with an Agent Windows Service add this line to the Agent instance start script agent_<port>.cmd set JAVA_OPTIONS="-Xms128m" "-Xmx500m"
🌐
PortSwigger
portswigger.net › burp › documentation › desktop › troubleshooting › setting-java-options
Setting Java options - PortSwigger
April 10, 2026 - You can't use the file to configure any options for Burp Suite itself. To specify custom Java options, create a user.vmoptions file:
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › guides › troubleshoot › envvars002.html
The JAVA_TOOL_OPTIONS Environment Variable
April 21, 2026 - In these environments the JAVA_TOOL_OPTIONS environment variable can be useful to augment a command line. When this environment variable is set, the JNI_CreateJavaVM function (in the JNI Invocation API) prepends the value of the environment variable to the options supplied in its JavaVMInitArgs argument.
🌐
Reddit
reddit.com › r/java › why does the environment variable _java_options exist, applies to jlink images, takes precedence, and can't be disabled?
r/java on Reddit: Why does the environment variable _JAVA_OPTIONS exist, applies to jlink images, takes precedence, and can't be disabled?
May 4, 2024 -

I just spent a good chunk of time debugging an issue because a user had set _JAVA_OPTIONS to use a low Xmx value in their environment variables. This was an application created with jpackage, which should be fully standalone. It even had a custom Xmx value set in the JVM arguments for the image but the environment variable overwrote the value!

Isn't this like a huge design flaw? I can just do echo "_JAVA_OPTIONS=<Wacky VM options>" >> ~/.bashrc or setx to break literally every Java application on the system? (Edit: Maybe the initial security focus was wrong, changed it a bit to focus more on the design issues)

Who even thought that this would be a good idea with no option to disable this behavior?

🌐
JRebel
jrebel.com › blog › jvm-options-cheat-sheet
JVM Options Cheat Sheet | JRebel by Perforce
If you wanted to get a full list ... followed by a wealth of standard Java options. For this cheat sheet, we’ve picked a few out that we find most interesting. First of all, we’ll start with the common system property. This can be set on JVM creation like so:...
🌐
Delft Stack
delftstack.com › home › howto › java › _java_options
_JAVA_OPTIONS Environment Variable in Java | Delft Stack
October 18, 2023 - While _JAVA_OPTIONS is recognized by all Java applications, JAVA_TOOL_OPTIONS is specifically intended for tools and utilities that are part of the Java Development Kit (JDK), such as javac, java, javadoc, and others. This means that if you set JAVA_TOOL_OPTIONS, the options specified will only apply when running these JDK tools.
🌐
Stack Overflow
stackoverflow.com › questions › 33098147 › where-to-put-java-options
eclipse - Where to put "Java options" - Stack Overflow
Go to Run -> Run Configurations... menu, in the lookup menu on the left type Glassfish and select your launch configuration. In the Argument tab you will find a VM Arguments box - add your Java options there.
🌐
Oracle
docs.oracle.com › cd › E22289_01 › html › 821-1274 › configuring-the-jvm-java-options-and-database-cache.html
Configuring the JVM, Java Options, and Database Cache - Oracle Fusion Middleware Installation Guide for Oracle Unified Directory
5. Setting Up the Replication Gateway · 6. Configuring the JVM, Java Options, and Database Cache · Configuring the Default JVM and Java Arguments · The Java Properties File Format · Configuring JVM Options · To Specify the JAVA_HOME Environment Variable for a Specific Utility ·