UnixServerAdmin

Server Administration & Management

How to Set Java Home Directory & Path

1. Set JAVA_HOME & PATH for single user

Login to your account and open .bash_profile file:

# vi ~/.bash_profile

export JAVA_HOME=/usr/local/jdk1.6.0_27
export PATH=$PATH:/usr/local/jdk1.6.0_27/bin

2. Set JAVA_HOME / PATH for All User

You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:

# vi /etc/profile
———————————————————————
#Set JAVA_HOME as follows using syntax
export JAVA_HOME=/usr/local/jdk1.6.0_27
#Set PATH as follows:
export PATH=$PATH:/usr/local/jdk1.6.0_27/bin
———————————————————————

# which java

“OR”

Type following command to make soft links:

# ln -s /usr/local/jdk1.6.0_27/bin /usr/bin

# ln -s /usr/local/jdk1.6.0_27/bin/java /usr/bin/java

Advertisements

September 23, 2011 - Posted by | Java, Tips & Tricks, Unix/Linux | , , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: