0

I need to permanently change JAVA_HOME and JRE_HOME environment variables in Linux.

So far I've been doing export:

export JAVA_HOME=jdk-install-dir
export PATH=$JAVA_HOME/bin:$PATH

But after I close the terminal the changes go away. How do I make the change permanent?

If it helps I'm running Red Hat with Korn shell.

Thanks!

gibsonsg
  • 35
  • 2
  • 11

1 Answers1

4

Edit your ~/.bashrc file and place at the end:

export JAVA_HOME=jdk-install-dir
export PATH=$JAVA_HOME/bin:$PATH

You can even modify /etc/environment if you want it to persist for all users.

zwer
  • 24,943
  • 3
  • 48
  • 66
  • Ok thanks, I definitely need it globally. I see this in environment file # .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # User specific aliases and functions Do I just remove it all and add my exports? – gibsonsg May 20 '17 at 00:30
  • No, add it before that code... Although you might want to wait for user environment variables to be initialized and add it after that, it all depends when the initial PATH is defined and do you want to override whatever environment variables the user has set. – zwer May 20 '17 at 00:36