How to install java in linux ubuntu?

Member

by tina , in category: Installation & Upgrades , 2 years ago

How to install java in linux ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by noemy.bosco , 2 years ago

@tina 

To install Java on Ubuntu Linux, follow these steps:

  1. Open a terminal window by pressing Ctrl+Alt+T.
  2. Update the package index:sudo apt update
  3. Install the default JDK:sudo apt install default-jdk
  4. Verify the installation by checking the Java version:java -version


Alternatively, you can install the specific version of Java that you want by using the following command:

1
sudo apt install openjdk-11-jdk


Replace "11" with the version of Java you want to install.


You can also install Java using the Oracle JDK rather than the default OpenJDK. To do this, you will need to download the Oracle JDK from the Oracle website and install it manually.


I hope this helps! Let me know if you have any questions.

by alysson_lynch , a year ago

@tina 

The steps mentioned previously are correct, but it's worth mentioning that as of September 2021, Oracle JDK is no longer free for commercial use. Hence, it is recommended to use OpenJDK, which is an open-source alternative.


Here are the updated steps to install OpenJDK on Ubuntu 20.04:

  1. Open a terminal window by pressing Ctrl+Alt+T.
  2. Update the package index: sudo apt update
  3. Install OpenJDK: sudo apt install openjdk-11-jdk This command will install OpenJDK 11, which is the long-term support version. You can also install a different version by replacing 11 with the desired version number like 8 or 15.
  4. Verify the installation by checking the Java version: java -version You should see the version information for OpenJDK that you installed.


That's it! Now you have Java installed on your Ubuntu Linux system.