Java is a popular and versatile programming language used in a wide range of applications, from web development to mobile apps and enterprise systems. To make the process of installing and managing different Java versions more straightforward, we recommend using either SDKMAN or Jenv. In this blog post, we will walk you through the steps to install Java using SDKMAN, with a focus on Amazon Corretto 11, a reliable and long-term support distribution of OpenJDK.
SDKMAN is a powerful tool that simplifies the installation and management of various software development kits (SDKs), including Java. With SDKMAN, you can easily switch between different Java versions, making it an ideal choice for developers who work on multiple projects with varying Java requirements.
To get started, let’s install SDKMAN on your system. Open a terminal and run the following command:
$ curl -s "https://get.sdkman.io" | bash
This command will download and install SDKMAN on your machine.
After the installation is complete, refresh your session or open a new terminal to ensure SDKMAN is active. Use the following command:
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
Now, SDKMAN is ready to use.
Amazon Corretto is a no-cost, multi-platform, production-ready distribution of OpenJDK. We highly recommend using Corretto 11, as it provides long-term support and regular updates. To install Corretto 11 using SDKMAN, run the following command:
$ sdk install java 11.0.18-amzn
Please note that the version number “11.0.18-amzn” may change with newer releases. Be sure to check the official Amazon Corretto website for the latest version.
Once the installation is complete, let’s verify that Java is correctly installed. Run the following command to check the Java version:
$ java -version
If everything is set up correctly, you should see an output similar to this:
openjdk version "11.0.18" 2023-01-17 LTS
OpenJDK Runtime Environment Corretto-11.0.18.10.1 (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.18.10.1 (build 11.0.18+10-LTS, mixed mode)
To avoid any potential issues with Java applications, it’s essential to set up the JAVA_HOME environment variable and update your PATH to include the Java installation. Open a new terminal and run the following commands:
$ echo $JAVA_HOME
This command should display the path to your Java installation directory.
$ echo $PATH
The output should include the path to your Java bin directory.
Congratulations! You have successfully installed Amazon Corretto 11 using SDKMAN. You can now enjoy the benefits of a stable and well-supported Java distribution, perfect for your development needs. Whether you’re working on personal projects or professional endeavors, Amazon Corretto 11 ensures a reliable and efficient Java environment. Remember, SDKMAN allows you to manage multiple Java versions effortlessly, making it an invaluable tool for any Java developer.
Alternatively, you can use Jenv for Java environment management, which provides similar benefits to SDKMAN. Feel free to explore both options and choose the one that best suits your workflow.
Reference
https://sdkman.io/
https://www.jenv.be/