Monday, June 20, 2005

Set the path to java in your /etc/profile in Linux

'javac' and 'java' commands in Linux terminal

Those two commands above weren't working for me this morning after a fresh install of Kubuntu Linux on my work machine. I understand that normally Kubuntu would modify the appropriate paths to make the compile and run commands work. However, I needed an older version of java, and to hunt for that package through Kynaptic would have been more trouble than it was worth (maybe). So the file was downloaded by itself, and installed. But that left the paths in a state of non-existance. So in order to get them working I had to do the following:

1. Open '/etc/profile' as super in a text editor. In Kubuntu it would be:

> sudo emacs /etc/profile
password:

2. Just before the last two lines of the file (your version of java where appropriate) add the following line:

export PATH=$PATH:/usr/local/j2sdk1.4.1_08/bin

where the last two lines are:

export PATH

umask 022

3. Refresh your /etc/profile by either logging out and back in, or in a terminal type:

> source /etc/profile

[EDIT]: After setting up a new install it would appear that going through the package manager makes this job so much easier. You can, of course, do it manually if you like. But using a package manager like apt-get sets up all paths for you.

-And that should do it

No comments:

Followers