I need to add -Dsun.java2d.opengl=true to my java applications, otherwise they freeze up.

Is there any way to force this system wide, so I don't have to modify the configuration file/script of each java application?

  • 1
    Can you put this into a JAVA_TOOL_OPTIONS environment variable that is inherited by all processes that may launch your java apps? Oct 6, 2015 at 4:41

2 Answers 2


For a quick and hackish fix, you could do something like:

# type java
java is /usr/bin/java
# mv /usr/bin/java{,.real}
# cat >>/usr/bin/java <<'EOF'
exec java.real -Dsun.java2d.opengl=true "$@"
chmod +x /usr/bin/java

This replaces your java executable with a shell script that calls the real one, with its given arguments, except with that setting prepended.

  • Don't do such hacks. use $PATH and your distributions mechanisms. Oct 5, 2015 at 23:21
  • It's not clear to me that there is a distribution-agnostic way to say "replace this package-controlled file with an arbitrary different one", nor even that any given distribution will have such a method at all. If the question had been specific to a given distribution, or even mentioned one, it might have been worth researching its specific mechanism.
    – Tom Hunt
    Oct 5, 2015 at 23:23
  • It doesn't need to be agnostic (but $PATH is, and Mark mentioned another one). He only has one (unfortunately he didn't both to include which). But the way you propsed will likely be destroyed on the next update. Oct 6, 2015 at 6:09

Have you looked at the .properties files in


or the equivalent configuration directory of the JVM that you are using?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .