Originally Posted by Les62
Rather than putting it in your home directory .bashrc, I would put it into /etc/bashrc That way the variable will be available for all users (root included).
I believe the "approved" way of doing this for the whole system is to create a new file in /etc/profile.d/ rather than editing /etc/bashrc directly. (If you edit /etc/bashrc and bash is updated, you might get your edits overwritten, or you might not get the file updated.)
su -c 'gedit /etc/profile.d/my-java-environment.sh'
enter the line listed above by vefonda, save and exit.
Changes to your own profile or the system profile will only affect new shells, so to see the effect you can just close the current terminal window, and open a new one (or log out and in again).