Search code examples
bashmavenjava-home

Log: "bash: export: "PATH.": not a valid identifier" when opening terminal on Ubuntu


Whenever I open a terminal, a message appear on top of it saying what I wrote in the title. I think I messed up with the /etc/profile file when trying to get maven work. I read some infos on exporting variables, but couldn't find my error, since I followed a guide that worked fine for other people.

The profile file I mentioned has these lines at bottom:

JAVA_HOME=/usr/local/java/jdk1.8.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/local/java/jre1.8.0
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

Setting $JAVA_HOME let me use properly Maven, but creates this annoying message. Can you help me?


Solution

  • As others mentioned in the comments, you are trying to export PATH. instead of PATH somewhere. You might want to check /etc/profile, ~/.bashrc and ~/.bash_profilefiles and try to find this invalid export.

    The source you provided is technically ok and you don't need to add any $ signs. Your PATH will contain $HOME/bin value twice though. You might want to change it to look like this:

    export JAVA_HOME=/usr/local/java/jdk1.8.0
    export JRE_HOME=/usr/local/java/jre1.8.0
    export PATH="$PATH:$HOME/bin:$JAVA_HOME/bin:$JRE_HOME/bin"