Ubuntu 运行 java -version 命令,提示:The program 'java' can be found in the following packages ...

Ubuntu 运行 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: apt install 

解决办法:

1、配置JDK

修改配置文件

vi  /etc/profile

增加以下内容

# Java
export JAVA_HOME=/usr/java/jdk1.8.0_212
export PATH=$PATH:$JAVA_HOME/bin

更新配置文件

source /etc/profile

2、重启VMware虚拟机

你可能感兴趣的:(Ubuntu 运行 java -version 命令,提示:The program 'java' can be found in the following packages ...)