To be able to compile your Java code, you'll need the JDK (Java Development Kit) installed on your computer. Follow along to find out how to install the OpenJDK using only two simple commands!
Check whether a JDK is already installed
Sometimes, the Java Development Kit is already installed on some systems. To check whether you've already got it, run the following command in your terminal (CTRL+ALT+T):
javac -version
If this command doesn't return an error but something like "javac ", you've already got the JDK.
Installing OpenJDK 💻
The OpenJDK is a very popular open-source third-party version of the official OracleJDK. It offers the same functionalities as the official one.
Before starting to install it, you should make sure that your system is up to date:
sudo apt-get update && sudo apt-get upgrade -y
Once you've done that, you can start installing OpenJDK by running the following two commands:
sudo apt-get install openjdk-18-jre
sudo apt-get install openjdk-18-jdk
As you probably noticed, we're also installing the JRE (Java Runtime Environment) to be able to execute Java programs.
That's it!
Hint
If you want to read more on this topic and find out how to install the official Oracle JDK on Linux and on Windows, you can have a look at my complete guide.
Top comments (0)