Java JDK vs JRE
When installing Java on Ubuntu 24.04, a common concern is understanding the difference between JDK and JRE and knowing which to install. Here’s the thing: Java Development Kit (JDK) comprises all the required tools to develop Java applications. It comprises of the Java compiler and debugger and for someone looking to create Java apps, you must have JDK installed.
As for Java Runtime Environment(JRE), it is required for anyone looking to run Java applications on their system. So, if you only want to run Java applications without building them, you only need to install JRE and not the JDK.
As a programmer, you will likely develop and run Java applications. Therefore, you must install JDK and JRE for everything to work correctly.
How to Install Java on Ubuntu 24.04
Installing Java only requires access to an internet connection. Again, when you install the JDK, it should install the default JRE by default. However, that’s not always the case. Besides, if you want a specific version, you can specify it when running the install command.
Here, we’ve provided the steps to follow to install Java quickly. Take a look!
Step 1: Update Ubuntu’s Repository
Updating the system repository ensures that the package you install is the latest stable version. The update command refreshes the sources list, and when you install Java, you will have the updated source index for the latest version.
Step 2: Install Default JRE
Before we can start installing Java, first verify that it isn’t already installed on your Ubuntu 24.04 by checking its version with the following command.
If Java is installed, you will get its version displayed on the output. Otherwise, you will get an output showing ’Java’ not found.
Otherwise, install the default JRE using the below command.
The installation time will depend on your network’s speed.
Step 3: Install OpenJDK
After successfully installing JRE, you are ready to install OpenJDK. Here, you can choose to install the default JDK, which will install the available version. Alternatively, you can opt to install a specific JDK version depending on your project requirements.
For instance, if we want to install OpenJDK 17, we would execute our command as follows.
During the installation process, you will get prompted to confirm a few things. Press ’y’ and hit the enter key to proceed with the installation. Once the installation is complete, you will have Java installed on your Ubuntu 24.04 and ready for use.
The last task is to verify that Java is installed. By checking the version, you will get an output showing which version is installed. If you want a different version, ensure you specify it in the previous commands, as your project requirements could be different.
For our case, the output shows that we’ve installed Java v21.0.3 .
Conclusion
Installing Java on Ubuntu 24.04 isn’t a complicated process. However, you must know what your project requirements are to guide which version you install. To recap, installing Java requires you to first update the repository. Next, install JRE and then specify what OpenJDK version to install. You will have managed to install Java on Ubuntu 24.04, and this post shares more details on each step.
Discover more from Ubuntu-Server.com
Subscribe to get the latest posts sent to your email.