LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-06-2006, 02:47 PM   #1
DarkLeon
LQ Newbie
 
Registered: Nov 2006
Posts: 6

Rep: Reputation: 0
How do you set the PATH variable ?


I am still trying to install java on my computer and now I need to set the PATH variable but I have no idea where to look, begin, or anything else. I appreciate if anyone can help me, thanks

P.S. I don't know if its important but I have ubuntu linux
 
Old 11-06-2006, 02:55 PM   #2
caps_phisto
Member
 
Registered: Sep 2004
Location: NH
Distribution: FC6, FC1-4, RH9, Gentoo 2006.0/1, Slackware 10.1/2,11, Vector SOHO 5.0.1
Posts: 237

Rep: Reputation: 30
PATH can be set two ways:

Temporary:
Code:
export PATH=$PATH:<path to java location>
Permenant:
Take your favorite text editor and open ".bash_profile" or ".profile" in your home directory. Then find the PATH line and add the java location at the end. If there is no PATH line in the file, add the above temporary line. Then re-login.
 
Old 11-06-2006, 02:56 PM   #3
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
in the console,
Code:
export PATH=$PATH:/your/new/path
which should take the existing PATH variable, add /your/new/path to it and then export it. This will probably only stay for as long as you're logged in, so you'll need to edit .bashrc or some system-wide config file to add the following command to the login sequence to have it work all the time (if it's only for your user, edit your ~/.bashrc and add the above line there, altered for your own needs).
 
Old 11-06-2006, 03:10 PM   #4
DarkLeon
LQ Newbie
 
Registered: Nov 2006
Posts: 6

Original Poster
Rep: Reputation: 0
I am still confused where would I go to change the PATH varible permenantly and I also need to change to change the CLASSPATH permenantly also
 
Old 11-06-2006, 03:17 PM   #5
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Hi DarkLeon, you make me guess, so please correct me if my assumptions are wrong, and hopefully I can answer better.

Did you get java from Sun? I assume you installed it in, e.g., in /usr/java/j2sdk1.4.2_06. Probably your version varies. My convention is a symlink /usr/java/jdk pointing to the former, so I can switch versions easily -- set yours up as you like.

Why do you want to set the PATH variable? I'll assume you'd like your shell to understand commands like javac, appletviewer, jar etc. instead of /usr/java/j2sdk1.4.2_06/bin/javac and so on.

To answer the title question, it depends on your shell. I'll assume you also want /bin, so ls works. In tcsh or csh:
Code:
set path = (/usr/java/jdk/bin /bin)
or
Code:
setenv PATH /usr/java/jdk/bin:/bin
Those two are exactly equivalent. In reality you'll want more directories, for all commands that you ever type -- e.g., /usr/bin, /usr/local/bin, /sbin, /usr/sbin, /usr/local/sbin. Probably you'll just append /usr/java/jdk/bin to what you already have, i.e.,
Code:
set path = ($path /usr/java/jdk/bin)
In bash:
Code:
PATH=$PATH:/usr/java/jdk/bin
 
Old 11-06-2006, 03:20 PM   #6
DarkLeon
LQ Newbie
 
Registered: Nov 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks a lot I'll try that now,

How about setting the CLASSPATH ?
 
Old 11-06-2006, 03:26 PM   #7
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Quote:
Originally Posted by DarkLeon
I am still confused where would I go to change the PATH varible permenantly
If your shell is csh or tcsh, edit ~/.login in your favorite editor (e.g., emacs). That's for the permanence. Then source ~/.login to make it take effect right away. For bash, edit as caps_phisto suggests, then . the file.

Quote:
and I also need to change to change the CLASSPATH permenantly also
Essentially the same. In the same file, add a line setenv CLASSPATH yadayada (for tcsh/csh) or export CLASSPATH=yadayada for bash, or
Code:
CLASSPATH=yadayada
export CLASSPATH
for sh (the Bourne shell). The latter works for bash too, but not the other way.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set PATH variable for command tracert? princegbenga Linux - Software 2 06-14-2007 07:48 AM
how to set $PATH variable definitely unihiekka Linux - Software 2 12-15-2005 10:12 AM
Set the path systemwide/Set the path for a user with Slackware jayhel Slackware 1 06-12-2005 12:24 AM
Where to set system PATH variable Cybers19 Linux - Newbie 4 05-05-2004 01:46 PM
How to set PATH How do I set PATH environment variable? Tranquil Linux - Newbie 3 11-02-2003 02:52 AM


All times are GMT -5. The time now is 02:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration