关于JDK

openjdk和oracle-java

1
2
3
4
# openjdk-8-jdk, openjdk-8-jdk-headless, openjdk-8-jre, openjdk-8-jre-headless
$ sudo apt install openjdk
# oracle-java8
$ sudo apt install oracle-java

安装后:

1
2
3
4
5
6
7
angi@angi-deepin:/usr/lib/jvm$ ls -l
总用量 8
lrwxrwxrwx 1 root root   24 1月   6  2017 default-java -> java-1.8.0-openjdk-amd64
lrwxrwxrwx 1 root root   20 11月  3  2016 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64
drwxr-xr-x 7 root root 4096 9月   1 09:21 java-8-openjdk-amd64
drwxr-xr-x 8 root root 4096 9月   1 14:33 java-8-oracle
angi@angi-deepin:/usr/lib/jvm$ 

java -version结果:

1
2
3
4
5
6
7
8
9
angi@angi-deepin:/usr/lib/jvm$ java-8-oracle/bin/java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
angi@angi-deepin:/usr/lib/jvm$ java-8-openjdk-amd64/bin/java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-8u141-b15-3-b15)
OpenJDK 64-Bit Server VM (build 25.141-b15, mixed mode)
angi@angi-deepin:/usr/lib/jvm$ 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
angi@angi-deepin:/etc/alternatives$ which java
/usr/bin/java
angi@angi-deepin:/usr/bin$ ls -l |grep java
lrwxrwxrwx 1 root root            22 9月   1 14:33 java -> /etc/alternatives/java
lrwxrwxrwx 1 root root            23 9月   1 09:21 javac -> /etc/alternatives/javac
lrwxrwxrwx 1 root root            25 9月   1 09:21 javadoc -> /etc/alternatives/javadoc
lrwxrwxrwx 1 root root            23 9月   1 09:21 javah -> /etc/alternatives/javah
lrwxrwxrwx 1 root root            23 9月   1 09:21 javap -> /etc/alternatives/javap
lrwxrwxrwx 1 root root            24 9月   1 09:58 javaws -> /etc/alternatives/javaws
angi@angi-deepin:/etc/alternatives$ ls -l |grep java
...
lrwxrwxrwx 1 root root  41 9月   1 09:21 jar -> /usr/lib/jvm/java-8-openjdk-amd64/bin/jar
lrwxrwxrwx 1 root root  51 9月   1 09:21 jar.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/man/man1/jar.1.gz
lrwxrwxrwx 1 root root  47 9月   1 09:21 jarsigner -> /usr/lib/jvm/java-8-openjdk-amd64/bin/jarsigner
lrwxrwxrwx 1 root root  57 9月   1 09:21 jarsigner.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/man/man1/jarsigner.1.gz
lrwxrwxrwx 1 root root  46 9月   1 14:33 java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
lrwxrwxrwx 1 root root  56 9月   1 14:33 java.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz
lrwxrwxrwx 1 root root  43 9月   1 09:21 javac -> /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
lrwxrwxrwx 1 root root  53 9月   1 09:21 javac.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/man/man1/javac.1.gz
lrwxrwxrwx 1 root root  45 9月   1 09:21 javadoc -> /usr/lib/jvm/java-8-openjdk-amd64/bin/javadoc
lrwxrwxrwx 1 root root  55 9月   1 09:21 javadoc.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/man/man1/javadoc.1.gz
lrwxrwxrwx 1 root root  43 9月   1 09:21 javah -> /usr/lib/jvm/java-8-openjdk-amd64/bin/javah
lrwxrwxrwx 1 root root  53 9月   1 09:21 javah.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/man/man1/javah.1.gz
lrwxrwxrwx 1 root root  43 9月   1 09:21 javap -> /usr/lib/jvm/java-8-openjdk-amd64/bin/javap
lrwxrwxrwx 1 root root  53 9月   1 09:21 javap.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/man/man1/javap.1.gz
lrwxrwxrwx 1 root root  48 9月   1 09:58 javaws -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/javaws
lrwxrwxrwx 1 root root  58 9月   1 09:58 javaws.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/javaws.1.gz
...

切换JDK

1
2
3
4
5
6
7
8
9
10
$ sudo update-alternatives --config java
有 2 个候选项可用于替换 java (提供 /usr/bin/java)。

  选择       路径                                          优先级  状态
------------------------------------------------------------
* 0            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      自动模式
  1            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      手动模式
  2            /usr/lib/jvm/java-8-oracle/jre/bin/java          80        手动模式

要维持当前值[*]请按<回车键>,或者键入选择的编号:

IBM JDK

IBM JDK