• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting PATH variable and linux

 
david allen
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to set the PATH variable. I issue the following command
PATH=$PATH/usr/java/j2sdk1.4.2/bin
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
david
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Linux forum...
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 java.sh 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:
</pre></code>
This gets executed for all users, and sets the environment correctly for them all.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic