

We see that java and javac are managed by alternatives. First, lets see which binaries are managed by alternatives: JDK 8 has been given a higher priority on RHEL-8 than JDK 11. The alternatives system uses priorities in order to determine which JDK should be available via /usr/bin/java. This means a system administrator can switch the system java (or javac) to be something other than the default, JDK 8. Java and javac binaries on RHEL 8 are managed by the alternatives system. Selecting Java versions with alternatives Select the JDK on a per-application basis by setting JAVA_HOME.

Switch java and javac binaries system wide via alternatives.There are two ways to select the Java version you want: OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode) OpenJDK Runtime Environment (build 1.8.0_181-b13) That’s why you get this output when running java -version on a fresh RHEL 8 install: At this point in time, JDK 8 is the main JDK on RHEL 8. In the previous step, we installed JDK 8 and JDK 11 in parallel. $ sudo yum install java-1.8.0-openjdk-devel java-11-openjdk-devel maven If you already know that RHEL packages are OpenJDK builds, yum list available might be useful too:įor the purpose of this article, we are going to install JDK 8 and JDK 11 in parallel, and also install maven: The -devel packages will pull in -headless packages as a dependency. For the purpose of this article, we’re interested in the development kits, so we’ll install the -devel sub-packages instead. This command tells us that packages java-1.8.0-openjdk-headless and java-11-openjdk-headless both provide the java binary. In order to figure out which RPM packages to install, we can ask the packaging system which ones provide the java binary: Let's consider we have a freshly commissioned Red Hat Enterprise Linux 8 machine and we'd like to use it for running Java applications. If you prefer to watch a short 4 minute demo video, here it is: Yes, with JDK 11 you can directly run Java source files. $ /usr/lib/jvm/java-11-openjdk/bin/java HelloWorld.java Then run Java “Hello World” as follows: $ cat > HelloWorld.java HelloWorld.java <