[arch-dev-public] JAVA_HOME in systemd

Guillaume ALAUX guillaume at archlinux.org
Wed Feb 6 05:50:22 EST 2013

Hi all,

I should have posted this a long time ago as suggested by Andy.

Basically I would like some advice from the systemd gurus on how to
provide a common place to set JAVA_HOME in systemd service files.

As you know all Java apps need JAVA_HOME to be set. But as systemd
service files do not inherit the shell's environment, all Java service
files will need to declare a
"Environment=JAVA_HOME=/lib/jvm/java-7-openjdk". Needless to say that
this is hardcoding the path and if one wants to change it for another
JVM, he/she will have to fix all service files.

Hence I was thinking about a common EnvironmentFile to hold this value
once and for all. I know these EnvironmentFile _should_ be avoided but
I think we are in a case where it could be tolerated. All Java service
file could then just refer to it throught
"EnvironmentFile=/the/path/to/this/file". Also it could be parsed by
/etc/profile.d/jre.sh to set the shell's environment.

So is there a simpler to do that in systemd? Or does this sound ok to
you? Also if it sounds OK, is there a standard place to put systemd
environment files like such?



More information about the arch-dev-public mailing list