Where can I set global Java Options?

I have horrible, improperly-rendered fonts in Java programs such as jabref and rubymine. This can be fixed by running

_JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on' jabref

I understand that I could export these Java options as environment variables, and launch the programs from the command line. However, is there a way to set these options globally, so that all Java programs recognise them, no matter how they are launched?

I’m also know that I could modify all the *.desktop files for my Java programs, but I’m looking for a global solution.

I am using java-7-openjdk on Arch Linux. (FWIW this used to be okay with the now-broken jre7-openjdk-headless-infinality installed.)

Asked By: Sparhawk


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.


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.

Answered By: Michael Homer
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.