Pages

Wednesday, 31 March 2021

How to Install and Uninstall Java on Ubuntu

Step1: Installing Java on Ubuntu

You can install one or several Java packages. You can also decide which version you want on your system by installing a specific version number. The current default and LTS version is Java 11.

Install OpenJDK

1. Open the terminal (Ctrl+Alt+T) and update the package repository to ensure you download the latest software version:

sudo apt update

2. Then, you can confidently install the latest Java Development Kit with the following command:

sudo apt install default-jdk

Install Specific Version of OpenJDK

You may decide to use Open JDK 8, instead of the default OpenJDK 11.

To do so, open the terminal and type in the following command:

sudo apt install openjdk-8-jdk

Once the installation process is complete, verify the current Java version:

java -version; javac -version

How to find the OpenJDK directory with the following command:

readlink -f /usr/bin/javac

How to Set Default Java Version

As you can have multiple versions of Java installed on your system, you can decide which one is the default one.First, run a command that shows all the installed versions on your computer:

sudo update-alternatives --config java

step 2: Uninstall Java on Ubuntu

In case you need to remove any of the Java packages installed, use the apt remove or purge command. To remove Open JDK 11, run the command:

sudo apt remove default-jdk

To uninstall OpenJDK 8:

sudo apt remove openjdk-8-jdk

2nd Method:

1. sudo dpkg --list | grep -i jdk 

2. sudo apt-get purge Oracle-java8-installer

No comments:

Post a Comment

Friends-of-friends-Map Reduce program

Program to illustrate FOF Map Reduce: import java.io.IOException; import java.util.*; import org.apache.hadoop.conf.Configuration; import or...