0

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?

5 Answers5

3

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.

Phil Hollenback
  • 14,947
  • 4
  • 35
  • 52
1

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

cat -tve .bashrc

worked for me.

Skalli
  • 138
  • 5
0

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

Riaan
  • 421
  • 5
  • 13
0

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.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
Alex
  • 1,103
  • 6
  • 12
0

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.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151