Getting Java

Where you get Java from does depend on your operating system/platform and whether you are installing a development environment. I will leave IDEs for another day and focus on the basic Java Virtual Machine (JVM) here.

The first question is, are you developing a Java solution and need a compiler or are you just executing supplied Java files, most likely JAR (Java Archive) files and thus you just need the Java Runtime Environment (JRE) or do you need the Java Development Kit (JDK) as well. Generally you can easily answer this yourself, although some software actually needs a full JDK, so check the software's system requirements. Recently Oracle stopped supplying a Java Runtime Environment (JRE) and only supplied a JDK (Java Development Kit), replying on the use of jlink to "build" a JRE. However, some JVM suppliers have started doing a JRE. You may be aware that the software you want uses Java and some software vendors choose to bundle this themselves and hence deploy it as part of their installer into their own directory tree.

Next is the question of how to get Java. With Linux you would be well advised to use your distribution's package manager and standard deployment mechanism, through which you will probably get Oracle's OpenJDK. With Windows or Mac you will need to visit Java SE - Downloads | Oracle Technology Network | Oracle and download what you need. However you would be well advised to read Java CPU and PSU Releases Explained to understand the different releases but in general stick to the "CPU" releases, which are the odd numbered versions.

A good general starting point is OpenJDK which has downloads for past, current and pre-release Java Development Kits and Runtimes, however AdoptOpenJDK - Open source, prebuilt OpenJDK binaries is easier to use quickly.

It is worth highlighting that IBM have their own JVM called J9, which supports their hardware platforms and is it the core of the WebSphere solutions.

OpenJDK

The OpenJDK Community is where the reference implementation of the Java Platform Standard Edition is created. It has groups which focus on areas of common interest, like the compiler or security, as well as projects that generally are bigger changes in the JDK. There is a Governing Road to look after the structure and organisation.

The JDK Project is the most important project, so it has the most formal process, specifically the JDK Enhancement Proposals, aka JEPs manage the change process, non-trivial changes to the JDK code base.

OpenJDK does not produce any binaries.

There are Oracle OpenJDK binaries, but also Oracle JDK binaries that can be supported. The Oracle JDK is patched and maintained by Oracle and other vendors do the same, they all have minor differences around patches and build processes but must adhere to the Reference Implementation as defined by the OpenJDK.

Long Term Support or LTS releases are down to the build vendors, they can decide which version to offer support on and for how long.

Installing

It seems that now, cloud providers have got into providing their own builds of the JVM, two important ones in this space are:

Whilst they do their own thing to some extent, AdoptOpenJDK is still a good place to start.

AdoptOpenJDK

It is important to note that Oracle no longer provide free updates for commercial use of Java 8 or Java 11, which are the LTS (Long Term Support) releases. You can pay for this service from Oracle, but a good alternative is AdoptOpenJDK.

The AdoptOpenJDK project provides prebuilt OpenJDK binaries from a fully open source base and you can find more details at AdoptOpenJDK - Open source, prebuilt OpenJDK binaries. It is important to note that OpenJDK is the open source reference implementation that oracle and others use and that the AdoptOpenJDK project is backed by Amazon, IBM, Microsoft, Red Hat and others, as well as the developer community.

Temurin is a new JDK built by the Adoptium Project, which is what AdoptOpenJDK has become, it is nicely explain in this:

I have done some testing on Windows using the AdoptOpenJDK installers, and there are a number of things that are worth noting, but in short the installers work brilliantly and do what you would expect

  • You can install JDK 8, 11 and 15 side by side, although clearly your JAVA_HOME can only point to one of them and only one of them will be first in your path
  • The different JVMs for the version can be installed side by side, so both Java 15 HotSpot and Java 15 OpenJ9 can be installed
  • If you install Java 15 HotSpot and then run the installer for a newer build of Java 15 HotSpot, then it will remove the previous build of Java 15 HotSpot but leave everything else
Windows

Make sure your JAVA_HOME environment variable points to the root directory of the JDK, so on Windows some thing like C:\Dev\Java\jdk1.8.0_111 or wherever you installed it. This means that on Windows %JAVA_HOME%\bin\java -version will work. With recent versions of Java the installer sorts out the path for you but otherwise you can set it as follows: %JAVA_HOME%\bin.

Linux

Use your package manager, anything else will just be a world of pain. However your JAVA_HOME might not be set, so you will either need to do this in your profile or look at your distribution documentation for setting it system wide. Most Linux distributions have a number of versions of Java installed or support this and also provide easy ways to switch but this is usually done with soft links, so finding your home directory can involve following a number of links! On an Ubuntu box I did this export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386 and then $JAVA_HOME/bin/java -version works just fine.

macOS

If you go to Oracle's website you can download a DMG file for your Mac and install this, however most people recommend using brew to do this so
brew cask info java will tell you all about the version brew will install by default. In June 2018 this was Java 10 but I needed Java 8, so this would have been no good. If you do this: brew tap caskroom/versions and then do brew cask search java you will see java8 and java6 appear as options.
After this I could then do brew cask install java8 and everything worked. Brew defaults to installing the latest sable version and does not allow old versions, then the extra command to get these other versions working.

I have not used this myself but it you need multiple versions of Java on your Mac then read Multiple JVM versions on macOS.

Old Versions

If you need to work with an old version of Java, then here are some things to note:

  • Most recent Linux distributions use OpenJDK, which was initially based on JDK 7 and has a retro fitted Java 6 version
  • Working with an old Linux distribution that is not currently supported and hence its repositories have gone is a huge pain
  • Downloading old Linux JDKs from Oracle and trying to get them working is far from trivial, I failed
  • Windows is actually easier to get old version of Java working on

Hopefully my recent experience will become a thing of the past and clearly things change but my notes might help.