Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using a centos virtual machine instance. I have edited the /root/.bash_profile and set the JAVA_HOME path.

the changes are saved but when I type echo $JAVA_HOME, the command executes but show nothing.

typing which java shows some other folder, which doesnt exist.

please help me out

share|improve this question

You could also set JAVA_HOME by creating a shell script in /etc/profile.d/ directory, for example:

create file: /etc/profile.d/

with following contents:

export JAVA_HOME
export PATH

Please note that directory should target place were java was installed. One above should be proper when you install Oracle JDK.

Following variables will be set during system start.

share|improve this answer

Command from .bash_profile will be applied where user log on, try to logoff and logon or restart computer.

Do you use SUN JDK or Open JDK ?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.