How to set JAVA_HOME environment variables permanently such that it will not have to be set each time it has to be used
How to set JAVA_HOME environment variables permanently such that it will not have to be set each time it has to be used
How to edit .bashrc to add the lineexport JAVA_HOME=/usr/java/latest
If it is not broken, tweak it... If you break Fedora you get to keep both pieces :p
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.)
So: run
enter the line listed above by vefonda, save and exit.Code:su -c 'gedit /etc/profile.d/my-java-environment.sh'
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).
Please be careful if you take this course of action, I tried this and apparently made an error. My laptop wouldn't login and only recognized basic bash commands, if this happens boot fedora with text only, login to root user and use 'command -p rm <path-to-file>' to erase it.
Please be even more careful following advice in old forum threads from 2011. If you need assistance with Java issues with the current version of Fedora please open a new thread.