• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

setting PATH variable and linux

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Linux forum...
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic