It really becomes even more interesting for users who have .profile (for the old Bourne shell), which is automatically read with .bash_profile (ensuring compatibility). In any case, environment variables are read only once when the login shell is launched, and all sub-object objects inherit these variables for free .. bashrc for tty-dependent things and unlucky functions (the old sh used $ ENV, I think if it were set, for something like that).
Your use of ~ / .bash_profile looks great (although single quotes are more reliable than double quotes, which allow some replacements). Make sure you are logged out and back between editing this file and trying to test it, or use ". ~ / .Bash_profile" (there are no quotes and note the leading dot and space, since dot is the command here).
The article http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html describes some good things, like using ". ~ / .Bashrc" at the end of your ~ /. bash_profile (excepth which you should use -r, not -f). The comment about using export in your .bashrc is incorrect, you should not do this for two reasons (1) a rather insignificant performance limitation, (2) a rather high probability that some command that you execute will not receive an environment variable - in particular, things arising from the window manager menu and other places where the actual command prompt did not appear in any of their parents.
Finally, make sure that $ MESSAGE really exists in your environment - look at the output of the env command - if it is not there, the Java process will not see it if it does not create it internally and does not save it in its internal copy of the environment variables.
Another note: if you set env variables to .profile, use this syntax:
VAR = VALUE; export var
... since the old sh shell does not support "export VAR = VALUE". Using set -e before a bunch of them and set + e after, you can remove the need to use "export" in general, if I remember correctly.
source share