This post explains how I install the Oracle JDK on Fedora 27.
1. Download
Download the Oracle JDK tgz file from here: http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html
Validate the checksum against the published values listed here: https://www.oracle.com/webfolder/s/digest/10-0-1checksum.html
$ shasum -a 256 jdk-10.0.1_linux-x64_bin.tar.gz
2. Install
I like to install the JDK in /opt/java.
$ cd /opt/java $ tar -xf jdk-10.0.1_linux-x64_bin.tar.gz
Now there should be a directory on the system that looks like /opt/java/jdk-10.0.1. In order to make updating the JDK easier in the future, create a symlink at /opt/java/latest that points to the latest installed version. This way we won't have to update the alternatives every time we update!
$ ln -s jdk-10.0.1 latest
3. Update alternatives
Fedora ships with OpenJDK installed by default and there are a bunch of packages that depend on it. However, we can use the alternatives command to allow the Oracle JDK and OpenJDK to coexist.
First let's tell alternatives about the Oracle JDK binaries:
$ alternatives --install /usr/bin/java java /opt/java/latest/bin/java 1000 $ alternatives --install /usr/bin/javaws javaws /opt/java/latest/bin/javaws 1000 $ alternatives --install /usr/bin/javac javac /opt/java/latest/bin/javac 1000 $ alternatives --install /usr/bin/jar jar /opt/java/latest/bin/jar 1000
Now we can make sure the correct version of the java command is selected, and update the configuration if necessary:
$ alternatives --config java
4. Verify
Let's make sure the Oracle JDK version of /usr/bin/java is being used:
$ java -version java version "10.0.1" 2018-04-17 Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
Final Thoughts
When a new Oracle JDK is released, we can just install it in /opt/java and update the symlink!
No comments:
Post a Comment