I had installed java in ubuntu but when I set the java home in ~/.bashrc the command doesn't work I had used these commands in ~/.bashrc using this command
sudo gedit ~/.bashrc
# JAVA HOME directory setup
export JAVA_HOME =usr/lib/java/jdk1.8.0_111
set PATH = $PATH:$JAVA_HOME/bin
export PATH
after that every time I open a terminal this message shows to me
bash: export: `=usr/lib/java/jdk1.8.0_111': not a valid identifier
You should assign variables with no spaces. And it is better to quote strings in bash.
export JAVA_HOME="usr/lib/java/jdk1.8.0_111"
export PATH="$PATH:$JAVA_HOME/bin"
Do not use spaces in the variable assignment.
sudo gedit ~/.bashrc
# JAVA HOME directory setup
export JAVA_HOME=usr/lib/java/jdk1.8.0_111
export PATH=$PATH:$JAVA_HOME/bin
Avoid the spaces between variable assignments and recommend double-quoting the values assigned to avoid word-splitting done by shell.
export JAVA_HOME="usr/lib/java/jdk1.8.0_111"
export PATH="$PATH:$JAVA_HOME/bin"
Do re-check your JAVA_HOME
path, if it should start with a /
, since you were missing it as part of the question. The below might have been your actual path.
export JAVA_HOME="/usr/lib/java/jdk1.8.0_111"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.