View Full Version : setting the PATH variable for Java

September 9th, 2005, 02:59 PM
I just installed java JDK 1.5.0 for my studies in informatics. I've got it all running smoothly, but I'm not sure how to add the PATH varibale.

To run a java program in terminal i need to type:
$ /opt/jdk1.5.0_04/bin/java Program

When the path variable is set, I should be able to run it like this:
$ java Program

Probably a simple question, but the online guides that I've found differ from eachother, so if someone could simple tell me how its done in Ubuntu 5.04 I would really appreciate it! Thanks

September 9th, 2005, 04:57 PM
There are a couple of places
Global for all users
edit /etc/profile and add
export PATH

for individual users add the same thinkg to /home/user/.bash_profile

You'll have to restart your session for this to work the first time.

August 15th, 2006, 02:04 PM

sudo vi /etc/profile

Now add at the end of the file by moving the cursor down arrow, then press the 'i' key.

export PATH
export JAVA_HOME

Then press the ":" (colon key) followed by the
"wq" keys.

Logout and relogin.

Open a terminal window, enter the java -version
command, and should see the update Java JDK version.