Short story
I need a system level way to set the java.awt.headless
property to true
for all java invocations. That is, using -Djava.awt.headless=true
is not an option, since java is being invoked from places I don't have access to (e.g. from within another tool written in Java/C/etc.)
Long story
I'm using a bunch of tools written in Java (specifically Adobe's Air ADT) that rely on AWT classes. When I run these tools on the console they work fine. But when I run them from an SSH session they fail with java.lang.InternalError: Can't connect to window server - not enough permissions
. Googling around I found that setting java.awt.headless to true will fix the problem. It doesn't, and that's because ADT itself spawns children Java processes without -Djava.awt.headless=true
.
Is there any system-level way to ensure this property is set whenever Java is invoked? Maybe some system awt property file or equivalent?
Worst case scenario I could try replacing /usr/bin/java
with a shell script that adds this argument to "$@"
but I'm hoping to avoid that. (Update: Just to ensure my theory is right, tried this shell script hack and it does solve the problem. Just hoping for a cleaner solution)