Ubuntu has been incredibly successful in large part thanks to its ease of use and great packaging. However, one thing they don’t teach you is how to force your GNOME session to export environment variables to processes. When a process is launched from a terminal, you set these environment variables through .bash_profile
, .bashrc
, .login
or other similar files. You can’t simply do this in GNOME.
The problem I’m facing is that I need a way to set a JAVA_HOME environment variable in emacs. The naïve method is to create a launcher with the command JAVA_HOME=/usr/local/java/jdk1.6.0 emacs
, after all, such syntax works from the shell and launches Emacs with the variable set. However, the launcher mechanism in GNOME does not recognize this and will fail to launch.
The solution lies in a file that no one ever talks about, .gnomerc. If you add the following lines to it, you should be able to export that variable to all applications launching in GNOME: :::bash JAVA_HOME=/usr/local/java/jdk1.6.0 export JAVA_HOME
This is the same syntax you’ll expect in bash, so if you use bash, you may be able to get away with symlinking .gnomerc
from .bashrc
.