2

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?

Neel Shah
  • 319
  • 7
  • 16

2 Answers2

5

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
shanmuga
  • 4,329
  • 2
  • 21
  • 35
0

Make JAVA_HOME at the front of your path. Otherwise /usr/bin/java will come before /usr/lib/java in the path search. And lose that leading space as shanmuga points out.

PATH=$JAVA_HOME/bin:$PATH
selbie
  • 100,020
  • 15
  • 103
  • 173