LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Could not set enviroment variable properly (https://www.linuxquestions.org/questions/linux-newbie-8/could-not-set-enviroment-variable-properly-642325/)

JimOrJoe 05-15-2008 03:52 AM

Could not set enviroment variable properly
 
Hi, you:
I tried to set the environment variables on linux so I can develope java applications. However, after I appended /JDK/bin at the end of the $PATH variable and exported it, the basic shell commands like ls and cd went missing. I was careful enough to delimited the paths with ':'.
I know the subsequent paths rely on the preceding ones in the $PATH variable. Is there any recommended location in the $PATH where I should put JDK/bin?
Thanks and Best Regards
JimOrJoe

blackhole54 05-15-2008 06:40 AM

Quote:

Originally Posted by JimOrJoe (Post 3153831)
However, after I appended /JDK/bin at the end of the $PATH variable and exported it, the basic shell commands like ls and cd went missing.

cd is a shell "built-in" and doesn't depend on $PATH. If it stops working, something very strange is going on. ls is in /bin; unless you give the full pathname, the shell requires /bin to be in $PATH. My guess is you just made a typo. To append:

Code:

PATH=$PATH:/JDK/bin
If at any point you want to review the value of $PATH (say to check for typos):

Code:

echo $PATH
Adding one or more elements onto the end of $PATH shouldn't cause commands that were working to stop working.

Cyhaxor 05-15-2008 11:38 AM

also as
Code:

export PATH
in order to permanently change your path :)

JimOrJoe 05-15-2008 09:13 PM

Hi, Buddies up stairs:
Just so you know, I had this issue taken care of.
Strange as it is, it worked only if I ran the commands like this:
export JAVA_HOME=jdk path
export PATH=$PATH:$JAVA_HOME/bin
Thanks
JimOrJoe

eggixyz 05-15-2008 09:19 PM

Cool,

Sounds like the first you might have exported

PATH=$JAVA_HOME/bin:PATH

instead of

PATH=$JAVA_HOME/bin:$PATH

I've done it before, too. At those times, it's good to know the absolute path to all the commands you need to reset it :)

, Mike

blackhole54 05-16-2008 01:42 AM

Quote:

Originally Posted by Cyhaxor (Post 3154257)
also as
Code:

export PATH
in order to permanently change your path :)

This is kind of an esoteric point, but my experience has been that when you change what is already an environmental variable, you don't need to to export it again. And just so there is no misunderstanding about your word "permanently," changes to environmental variables only propogate to descendants of the process where they are changed. If you want the change to be permanent you need to add it to /etc/profile, ~/.bash_profile or some such so that it is executed every time you log in.


All times are GMT -5. The time now is 07:55 PM.