RHL 4.5: how to set JAVA_HOME permanently in the system?

epifanio67
epifanio67 used Ask the Experts™
on
hello Experts,

how do I set environmental variable JAVA_HOME permanently in my red hat box?

as root?

thx,
regards,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Developer
Commented:
add a script named "java.sh" to add the variable in /etc/profile.d/
(with "execute" permissions) if you're using bash as login shell

/etc/profile.d/java.sh

export JAVA_HOME=/usr/java/j2k1.x.x
export PATH=$PATH:$JAVA_HOME/bin

 

Author

Commented:
thank you...

Do I need to execute the file to set them?
./java.sh

if I log off the server, would the variable get unset?

thx so much...

Kerem ERSOYPresident
Commented:
Hi,

The contents of profile.d will be automatically executed with every interactive logon. so you don't need to run it explicitly.

When you logoff your shell will be removed from the memory along with the entire environment. But when you logon again it will be reestablished including your new java environment.

Cheers,
K.

Author

Commented:
thank you experts...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial