6

I type this: export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk so that I can access that directory by typing cd $JAVA_HOME but every time I close and open the terminal I have to do this again and again. Is there a way of saving this? I did some research but am not understanding how you could add it to the bash_profile.

I'm on the latest Fedora.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
SiZa
  • 63

1 Answers1

6

You need to add your export line in /your/home/directory/.bashrc, which is the Bash initialization file sourced when you start an interactive shell.

If you're using the GUI to edit the file, you should note that its name begins with a . so it's hidden in the GUI by default. To make it visible, assuming you're using Nautilus, you can press CTRL+H. If you're using some other file manager, look in its documentation for how you can show hidden files.

Simply edit your .bashrc and append your export line at its end. This should work when you open and close the terminal and should also be persistent across reboots.

Joseph R.
  • 39,549