1

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?

Šimon Tóth
  • 8,238

2 Answers2

0

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'
#!/bin/sh
exec java.real -Dsun.java2d.opengl=true "$@"
EOF
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.

Tom Hunt
  • 10,056
  • Don't do such hacks. use $PATH and your distributions mechanisms. – Has QUIT--Anony-Mousse Oct 05 '15 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 05 '15 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. – Has QUIT--Anony-Mousse Oct 06 '15 at 06:09
0

Have you looked at the .properties files in

/etc/java-8-openjdk

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