How to set JAVA_HOME environment variable for root user on AIX?

person sticking a post it on a white board with the words how to written on it

If you are following my previous post about installing Java 6 64bit on AIX 6.1 platform, next you have to set JAVA_HOME and PATH variables. If you want to set environment variables for non root users. You can set those variables in /home/<user>/.profile file.
For a root user, setting an environment variable is different. As you will not find it’s directory in /home.

There is a way for that. You can set envoirnment variable in /etc/profile. This will override all those envoirnment variables mentioned in .profile.

Setting variables in /etc/profile

For setting JAVA_HOME in /etc/profile enter following statements:

JAVA_HOME=/usr/java6_64/jre
export JAVA_HOME

PATH=$JAVA_HOME/bin:$PATH
export PATH

You have to login again to see the changes. I am using putty, so will re-open it and login with root user.

Verifying variables

To verify your changes you can echo JAVA_HOME and PATH variables.

# echo $JAVA_HOME
/usr/java6_64/jre

# echo $PATH
/usr/java6_64/jre/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin

# which java
/usr/java6_64/jre/bin/java

I am using Korn Shell. To know which shell you are using, you can echo SHELL.

# echo $SHELL
/usr/bin/ksh

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.