To set the path in .bash_profile

There are times when the applications need higher version of software than the existing version. For example, if you already have a lower version java installed in /usr/bin/java, and you need a higher version of jdk, download the latest version of jdk from the url:
If the path for the java installation is


Type the following command to know the exact path from where the java is run

which java

By default, all the softwares are run from /usr/bin or /usr/local/bin. If you would like to run the latest java installation, you need to set the path in .bash_profile.
vi ~/.bash_profile or
vi /home/username/.bash_profile
Add paths for JAVA_HOME and PATH by adding the two lines in .bash_profile
export JAVA_HOME=/home/username/softwares/jdk1.7.0_03/bin/java
export PATH=$PATH:/home/username/softwares/jdk1.7.0_03/bin
Now type the following command to make the changes effective
source .bash_profile
The command below should give you the path set in .bash_profile
which java
The following procedure can be used to set any other path in .bash_profile


Leave a Reply

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

You are commenting using your 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