gibsonsg gibsonsg -4 years ago 95
Linux Question

How do I permanently add an environment variable?

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!

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download