Before downloading a JDK from Oracle, you need to know two things. (1) You can't use that software in production without a paid license from Oracle (2) You can only get the current six-month release, not the long-term-support release there. For many users, the OpenJDK from http://adoptopenjdk.net is a better option. However, those downloads don't come with an installer. Here I provide simple installation instructions for Windows, Mac OS, and Linux.
As of JDK 11, the usage rules for the Oracle JDK are complex. However, there is a free alternative: OpenJDK. There is no functional difference between the Oracle JDK and OpenJDK. If you want to learn or teach Java, or develop software with Java, I suggest that you go with OpenJDK unless you have a specific business reason to use the Oracle JDK.
The AdoptOpenJDK foundation has committed to providing builds that integrate security fixes well beyond Oracle's six month window. Those builds don't come with installers, but it is easy enough to do the installation with a small amount of command-line fu.
Here is my set of instructions that are optimized for simplicity, predictability, and transparency.
very
long time—it's a Windows thing. When it is complete, you get an option “Open Folder”.
In the file explorer window, locate the Downloads directory and the file that you just downloaded—it will have a name starting with OpenJDK11-jdk_x64_windows_hotspot_11
. Right-click and select “Extract All”.
As extraction target, specify C:\Users\your user name
. In fact, you will be given a suggestion that starts with this folder—just erase everything after your user name.
The extraction can take a very long time—it's a Windows thing.
Wait for the process to finish.cmd
, and hitting Enter.
Then paste the following commands:
rd /s /q jdk-11 move jdk-11* jdk-11If the first command gives an error “The system cannot find the file specified”, that's ok—it simply means you didn't have a prior version.
jdk-11\bin\java --versionYou should get a response such as
openjdk 11 2018-09-25 OpenJDK Runtime Environment AdoptOpenJDK (build 11+28) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11+28, mixed mode)
setx PATH "%HOMEDRIVE%%HOMEPATH%\jdk-11\bin;%PATH%"
javaYou should get the same response as before.
java
command again.control
into the run dialog. Then hit Ctrl + Shift + Enter together to run as an administrator. Agree to running the control panel as administrator. Select System and Security → System → Advanced system settings → Environment Variables. In the System variables area, select PATH and click Edit. Then select any lines related to Java and hit Delete. Click Ok to close the open dialogs. Now open a new terminal and try the java
command again.c:\Users\your user name\jdk-11
. Some installers want to see the bin
folder or a specific file inside it. For example, Eclipse wants the javaw.exe
file inside the bin
folder.
OpenJDK11-jdk_x64_mac_hotspot_11_28.tar.gz
. Save the file to the Download
directory.tar xf Downloads/OpenJDK11*.tar.gz
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-11 sudo mv jdk-11+* /Library/Java/JavaVirtualMachines/jdk-11
$(/usr/libexec/java_home -v 11)/bin/java --versionYou should get a response such as
openjdk 11 2018-09-25 OpenJDK Runtime Environment AdoptOpenJDK (build 11+28) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11+28, mixed mode)
echo "PATH=\$(/usr/libexec/java_home -v 11)/bin:\$PATH" >> .bash_profile
javaYou should get the same response as before.
rm -f Downloads/OpenJDK11*.tar.gz
Download
directory as the target. When the download is complete, uncompress the archive into your home directory. Issue this command in the same terminal window that you opened previously.tar xf Downloads/OpenJDK11*.tar.gz
jdk-11
directory and rename the directory to jdk-11
:
rm -rf jdk-11 mv jdk-11+* jdk-11
jdk-11/bin/java --versionYou should get a response such as
openjdk 11 2018-09-25 OpenJDK Runtime Environment AdoptOpenJDK (build 11+28) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11+28, mixed mode)
echo "PATH=$(pwd)/jdk-11/bin:\$PATH" >> .bashrc
javaYou should get the same response as before.
Comments powered by Talkyard.