As of this writing, Java SE 12 is the latest version of Java that is available (I know that as I type this im going to have to update this at some point :-)). If you want to develop java programs using all the latest functionality of java you need to install Java JDK 12 on your machine. This post will detail how to do that for a Windows computer.
Like backgammon, Java is easy to pick up, hard to master, but extremely rewarding once you get there. Its possibly one of the most widely used programming environments available right now, as its cross platform, object oriented, and continuously improved with great new features added in each release.
New Features In Java 12
Downloading the JDK for Java 12
Navigate to https://www.oracle.com/java/technologies/javase-jsp-downloads.html and scroll down till you get to the Java SE 12 Section. Click on the Oracle JDK Download button.
Oracle JDK License Update
This will take you to the Java SE Development Kit 12 Downloads page. One thing to note here is that the Java licensing has changed since April 2019. Now to use java in a commercial setting (for example, if you are working in a company, government body or organisation of any kind) then you will need an Oracle license to use Oracle Java.
If you dont have the option to purchase a licence then you will need to use OpenJDK version of Java. OpenJDK is still a robust version of Java, but unlike the Oracle version it doesn’t come with commercial support. But if you are already using some of Oracles paid products in your organisation, such as Solaris OS or Oracle DB, check as you may get a license for Java included with those.
If you are using Java for personal use, such as learning Java or developing software for personal use at home, then the new license rules still allow you to use Oracle Java. Just make sure that if you are using Java at work, you are complying with the licence and using the appropriate version.
Oracle JDK Download
Scroll down the page until you see the versions available to download for Java SE Development Kit 12.0.2. For windows we have the choice of the auto installer executable or the zip file.
If you click on the executable for windows, you will be presented with a confirmation screen for accepting the Oracle License Agreement. Once you have read the license terms and are happy with them, click to accept the license then click to download.
If you havent already signed in, you will be presented with the Oracle login screen. Either login, or register and then login, and your download should start after that.
Installing The JDK
Once the executable installer has downloaded, click on it to begin the install. You may get windows asking you if you want to allow the installer to make changes, so click yes in this case as we know we are doing an install.
You will then get presented with the Java SE Development Kit 12.0.2 64 bit setup install window, so click next to continue
You will then see the install location confirmation screen, so click next to continue
You will then see the installer splash screen with the progress bar as it installs the Java JDK and JRE.
Once the install is complete you will see the install complete confirmation screen. Click Close and at that point you are done with the installer.
Checking The Java Environment
To make java accessible from the command link easily, it should be on your system path. You can check this by starting a command prompt and checking. Right click the start button then click command prompt.
At the command prompt, type java -version, and it will show you which version of java is currently setup on your path, or an error if not.
The version shows 1.8.0_221-b11. Which shows that our java 12.0.2 has not been added to the system path. This isn’t necessarily a problem. We can modify our system path to point to the version of Java that we just installed, or we can follow the steps below to be able to use multiple versions of Java on the same machine by using batch files.
Installing Multiple Versions Of Java
If you want to have multiple version of java available on your computer for some reason, such as you have a piece of software that demands a specific version of java, you can install java just as we have done here, and then use a windows batch file to point to a specific version of java.
Or you may want to point to the jdk instead of the JRE, for instance if you have some specific software that may need to compile code, so as software for developers. in that case what we would do would be to create a windows batch file that would modify the path so that the version of java we require is run instead of what has already been defined on the path.
set path=C:\Program Files\Java\jdk-12.0.2\bin;%path% java -version
We create a windows batch file by opening notepad, and then saving that with a .bat extension. If we then run that we get the below.
This does look the same as before as we havent actually installed an additional version yet, but if we check the path by typing path at the command line we can see that the one we sit is there first now.