Neel Shah Neel Shah - 5 months ago 8
Java Question

.bashrc giving error after settin $JAVA_HOME PATH

I am getting the following error after setting JAVA_HOME path in bashrc:

bash: export: `=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/java/jdk1.8.0_91/bin': not a valid identifier

bashrc file:

#JAVA HOME directory setup
export JAVA_HOME="/usr/lib/java/jdk1.8.0_91"
export PATH =$PATH:$JAVA_HOME/bin


When I do echo_$JAVA_HOME, I get the correct path as:
/usr/lib/java/jdk1.8.0_91

When I execute the command which java, I get the result as:
/usr/bin/java

What can be the possible solution to solve this problem?

Answer

In shell while setting a variable there should be no space between the valirable name and = character. Just change

export PATH =$PATH:$JAVA_HOME/bin

to

export PATH=$PATH:$JAVA_HOME/bin