问题
Currently working on Linux Cinnamon
. I have unistall/removed Open JDK
from my local drive. Then I checked java -version
via terminal and gives -
$ java -version
The program 'java' can be found in the following packages:
* default-jre
* gcj-5-jre-headless
* openjdk-8-jre-headless
* gcj-4.8-jre-headless
* gcj-4.9-jre-headless
* openjdk-9-jre-headless
Try: sudo apt install <selected package>
After that following the installation guide to install oracle jdk 8
for linux
. Then I just checked java -version
command through [I just unpack jdk
to /opt/java
]-
$ /opt/java/jdk1.8.0_112/bin/java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
I set my environment variable JAVA_HOME="/opt/java/jdk1.8.0_112"
[excluding bin
] to /etc/environment
using nano thereafter from JAVA_HOME setup tutorial -
# Java Home
JAVA_HOME="/opt/java/jdk1.8.0_112"
export JAVA_HOME
and refresh & checked my JAVA_HOME
as follows -
$ echo $JAVA_HOME
/opt/java/jdk1.8.0_112
After these setup while I am trying check java -version
via command it gives -
$ java -version
The program 'java' can be found in the following packages:
* default-jre
* gcj-5-jre-headless
* openjdk-8-jre-headless
* gcj-4.8-jre-headless
* gcj-4.9-jre-headless
* openjdk-9-jre-headless
Try: sudo apt install <selected package>
Can anyone tell me what is going on?
回答1:
Even once you set $JAVA_HOME
, you still need to add bin
to your $PATH
:
export PATH="$PATH:$JAVA_HOME/bin"
来源:https://stackoverflow.com/questions/40322674/java-is-not-working-in-linux-why