File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes setting PATH variable and linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "setting PATH variable and linux" Watch "setting PATH variable and linux" New topic

setting PATH variable and linux

david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
I am trying to set the PATH variable. I issue the following command
export PATH
The PATH is then set but if I close down the terminal window the changes are gone.
Please help as I have almost reached breakiing point
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Note that this is not a Java question at all; this probably belongs in "General Computing."
Anyway, you have to put the shell commands you're showing us into a file that is executed when your shell starts. Precisely -which- file to use depends on which shell you're using, and also to a lesser extent on the details of how your system is set up. Your best bet is to put those lines into a file in your home directory named .bashrc (note that the name starts with a period, making it an "invisible" file.)

[Jess in Action][AskingGoodQuestions]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Linux forum...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11778

Hi David,
Some options for you:
Edit the file <code>.bash_profile</code> (note the leading period) in your home directory. Put your path statment into there. Whenever you log in, this file is executed, and so the path should be set. (If you are using a different shell than bash, ask and someone can tell you the apropriate profile).
Alternatively, if this is something that all users are likely to want in their environment, then you could ask the administrator to add a file to the <code>/etc/profile.d/</code> directory. I have one in there called containing:<code><pre>
export JAVA_HOME=/usr/java/j2sdk1.4.0_01
export ANT_HOME=/opt/jakarta-ant-1.4.1
export PATH=${PATH}:${JAVA_HOME}/bin:${ANT_HOME}/bin:
This gets executed for all users, and sets the environment correctly for them all.
Regards, Andrew

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
I agree. Here's the link:
subject: setting PATH variable and linux
It's not a secret anymore!