java不能在linux下工作.为什么?
作者:互联网
目前正致力于Linux Cinnamon.我从我的本地驱动器中取消/删除了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>
之后安装指南安装oracle jdk 8 for linux.然后我通过[我只是解压缩jdk到/ 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)
我将环境变量JAVA_HOME =“/ opt / java / jdk1.8.0_112”[不包括bin]设置为/ etc / environment使用nano之后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,你仍然需要在$PATH中添加bin:
export PATH="$PATH:$JAVA_HOME/bin"
标签:java-home,java,linux 来源: https://codeday.me/bug/20190823/1702605.html