PDA

View Full Version : setting the PATH variable for Java



tidemann
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

ebrowne
September 9th, 2005, 04:57 PM
There are a couple of places
Global for all users
edit /etc/profile and add
PATH=${PATH}:/opt/jdk1.5.0_04/bin/;
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.

vcrfix
August 15th, 2006, 02:04 PM
Or,

sudo vi /etc/profile

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

PATH=/usr/java/jdk1.5.0_08/bin:${PATH}
export PATH
JAVA_HOME=/usr/java/jdk1.5.0_08
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.