将 Java 版本从 1.8.0_161 更改为 1.8.0_151 Ubuntu 16.04

将 Java 版本从 1.8.0_161 更改为 1.8.0_151 Ubuntu 16.04

我正在使用 ubuntu 16.04 LTS。

...$ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

...$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle

我曾尝试使用多个版本的java使用提到的答案是这个帖子

...$ which java
/usr/bin/java

从此链接下载 jdk 1.8.0_151:

http://www.oracle.com/technetwork/java/archive-139210.html

将其提取出来home/b/然后尝试帖子中提到的以下命令。

...$ export  PATH=/home/b/jdk1.8.0_151/bin:$PATH 

... $ which java
/usr/bin/java

我仍然得到相同的 java。

我也尝试过:

...$ sudo update-alternatives --config java

here is 1 choice for the alternative java (providing /usr/bin/java).

Selection    Path                                     Priority   Status

------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java   1081      auto mode
* 1            /usr/lib/jvm/java-8-oracle/jre/bin/java   1081      manual mode

这是我的$PATH:

...$ echo $PATH

/home/b/jdk1.8.0_151/bin:/home/junaid/anaconda2/bin:/usr/local/sbin:/usr/local/bin:
/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:
/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin

我是否应该删除 Java 并重新下载?如果是,那么该怎么做?

答案1

我遇到了以下问题:

>Checking build tools versions...
>************************************************************
>You asked for an OpenJDK based build but your version is
>java version "1.8.0_161" Java(TM) SE Runtime Environment (build 1.8.0_161-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode).
>************************************************************
>build/core/main.mk:175: error: stop.
>09:36:38 ckati failed with: exit status 1
>build/core/main.mk:21: recipe for target 'run_soong_ui' failed
>make: *** [run_soong_ui] Error 1

>#### make failed to build some targets (01:40 (mm:ss)) ####

通过从 $EXPORT 中删除 Oracle 路径,这个问题已经解决了。

相关内容