How to Install JDK on Windows, Linux, or MacOS easily
Almost every year a new JDK has released! By the time you have finished reading this post, it might since been upgraded again. However, you can always get the latest version simply by following the steps below and replacing the version number with the latest one.
JDK is a development environment for developing applications and tools based on Java. It can also be used for testing applications and program developed using the Java programming language.
There is an open source version of Java JDK ( OpenJDK ) that can be installed easily using the different methods. However, this post is going show you how to install free version easily and prepare your development system as well.
As Java developers, we have to work with different versions of Java from project to project. Installing different versions by hand and setting the PATH can become a real pain at times. SDKMAN is a command line tool that allows you to install different versions of Java, Gradle, Maven and more. SDKMAN also takes care of setting environment variables for you.
Installing SDKMAN
SDKMAN can be installed on Windows, Linux and MacOS. To install SDKMAN enter this command at the terminal:
$ curl -s “https://get.sdkman.io" | bash
Remember, SDKMAN requires a bash environment to run. On Windows, it can’t be natively installed; you need WSL or MSYS+MinGW. We no longer support Cygwin.
List Versions
To get a listing of Candidate Versions for Java use this command:
$ sdk list java
You see the result and then you can select the latest version from different providers.Let’s say you want to install Amazon Corretto 17 , then enter this command at the terminal:
$ sdk install java 17.0.11-amzn
After install finishes, you can set one JDK to be default one if you have installed more than one:
$ sdk default java 17.0.11-amzn
If you need the installation path, sdk install all candidate in home directory in this path:
~/.sdkman/candidates/java/
Enjoy it
$ java -version