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

link|improve this question
feedback

2 Answers

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

create file: /etc/profile.d/java.sh

with following contents:

JAVA_HOME=/usr/java/default
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
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.

link|improve this answer
feedback

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 ?

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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