java 在 linux 中不工作。为什么?
java is not working in linux. Why?
目前正在 Linux Cinnamon
。我的本地驱动器有 unistall/removed Open JDK
。然后我通过终端检查 java -version
并给出 -
$ 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>
之后按照安装指南为 linux
安装 oracle jdk 8
。然后我通过 [I just unpack jdk
to /opt/java
]-
检查了 java -version
命令
$ /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)
我使用 nano 将我的环境变量 JAVA_HOME="/opt/java/jdk1.8.0_112"
[不包括 bin
] 设置为 /etc/environment
from JAVA_HOME setup tutorial -
# Java Home
JAVA_HOME="/opt/java/jdk1.8.0_112"
export JAVA_HOME
并刷新并检查我的 JAVA_HOME
如下 -
$ echo $JAVA_HOME
/opt/java/jdk1.8.0_112
在我尝试通过命令检查 java -version
时进行这些设置后,它给出 -
$ 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>
谁能告诉我这是怎么回事?
即使您设置了 $JAVA_HOME
,您仍然需要将 bin
添加到您的 $PATH
:
export PATH="$PATH:$JAVA_HOME/bin"
目前正在 Linux Cinnamon
。我的本地驱动器有 unistall/removed Open JDK
。然后我通过终端检查 java -version
并给出 -
$ 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>
之后按照安装指南为 linux
安装 oracle jdk 8
。然后我通过 [I just unpack jdk
to /opt/java
]-
java -version
命令
$ /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)
我使用 nano 将我的环境变量 JAVA_HOME="/opt/java/jdk1.8.0_112"
[不包括 bin
] 设置为 /etc/environment
from JAVA_HOME setup tutorial -
# Java Home
JAVA_HOME="/opt/java/jdk1.8.0_112"
export JAVA_HOME
并刷新并检查我的 JAVA_HOME
如下 -
$ echo $JAVA_HOME
/opt/java/jdk1.8.0_112
在我尝试通过命令检查 java -version
时进行这些设置后,它给出 -
$ 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>
谁能告诉我这是怎么回事?
即使您设置了 $JAVA_HOME
,您仍然需要将 bin
添加到您的 $PATH
:
export PATH="$PATH:$JAVA_HOME/bin"