I just want to setup a system wide environment variable, JAVA_HOME
for all users, including root user.
Requirements:
- accessible to normal users
- accessible to root
- always loaded, not only for bash (gnome-terminal does not start a bash by default)
- to work on Ubuntu, Debian and optionally Red Hat
- great if addition could be easily scripted
Best Answer
For Ubuntu, and possibly other *nix platforms, add a new script in
/etc/profile.d
namedjava.sh
, such as:Other considerations that were ruled out:
/etc/environment
- works but is harder to maintain using other tools (or people will edit it); and/etc/profile
- same drawbacks as/etc/environment