Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to add JAVA_HOME and an updated PATH to my .bashrc file on Redhat Enterprise Linux.

My .bashrc file has only these two lines, but I get the error " : command not found "

#user specific environment and startup programs
export JAVA_PATH=/path/to/JDK
export PATH=$PATH:/path/to/JDK/bin

I'm not sure what this command not found thing is all about, I'm not even issuing a command. Is : a command?

share|improve this question
    
Are you sure .profile isn't being used instead? –  Nerdling Dec 28 '09 at 21:59

5 Answers 5

Yes, ':' is a valid command in bash, so that error message indicates that for some reason the shell is finding that as a command to execute in the .bashrc shell script. Try a few things:

  1. 'cat -tve .bashrc' to see if it has any hidden special characters that are messing things up.
  2. 'bash -x .bashrc' to see if executing your .bashrc directly causes problems.
  3. Place a 'echo $PATH' in the .bashrc before those two export commands, and see what your path is set to beforehand.

I suspect one of a the following possibilities:

  1. weird control characters causing unexpected issues
  2. .bashrc getting executed by a different shell (like /bin/sh)
  3. $PATH containing odd characters or values before this .bashrc runs

I believe the three troubleshooting ideas I've outlined should help you narrow that down.

share|improve this answer
1  
some double-quotes around the stuff after the = wouldn't hurt and might avoid problem #3... –  freiheit Dec 28 '09 at 20:31
    
I'd really like to hear what the ultimate problem turned out to be in this case. –  Phil Hollenback Dec 30 '09 at 20:19

Check if the .bashrc file contains any unnecessary spaces, tabs and newlines.

cat -tve .bashrc

worked for me.

share|improve this answer

Try this as a example - might help

export JAVA_HOME=/usr/java/jdk1.5.0_11

export PATH=$PATH:$JAVA_HOME/bin

Also read this if you do not understand: Redhat Documentation

share|improve this answer

od -c will also show you the file in all its glory in case of hidden characters.

But, put quotes around the value in VAR="" and you should be fine.

share|improve this answer

Another possibility is that prior to those lines $PATH has a space somewhere in it. It would be a good idea to remove that if it's there. But quoting your assignment as others have suggested is a good idea and may help if this is the case.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.