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!

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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?
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.