install java using apt

Install Java Using Apt-Get Command In Ubuntu

If you’re looking for how to install java 8 and 11 using the apt-get command in ubuntu, So you can install it because by default java is not installed. Update the Ubuntu machine using the command apt update

Update the packages in the ubuntu machine. I would suggest only on personal laptops. First, check java is installed or not using java -version.

install java ubuntu

Check Out: How To Protect EC2 Instance From Termination of Running instances

In order to install it, we have to run these commands. This command will install the Jara Runtime Environment(JRE) and might be your application needs it. so

apt install default-jre
Once it’s done, check the java version.

ubuntu install java 8

You may need the Java Development Kit(JDK) to compile the code then run the below command.

apt install default-jdk

Check Out: Learn Top 12 lsof Commands Example For Files In Linux 8

Once it’s installed, use this command javac -version

install java 11 ubuntu

The above commands will install the latest version of Java.

Install Specific Version of Java

we’re installing openjdk8 version using the command apt install openjdk-8-jdk

install java ubuntu

Once the installation finished. You can set the default java version using the below command.

update-alternatives –config java

how to install java 8 on ubuntu

Check Out: How To Create Automatic Backup of Volumes And EC2 On Amazon cloud

I will make java 8 to the default version in ubuntu.

In a similar way, you can install java JDK and JRE version 11 using the below commands.

apt install openjdk-11-jre

apt install openjdk-11-jdk

we can also set the javac using update-alternatives –config javac

Check Out: How To Install and Configure Mediawiki On CentOS / Redhat 7

if you require to set the JAVA_HOME environment variable. Simply use the update-alternatives –config java command to find the path and paste it inside.

vim /etc/environment

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java"

You’re done ubuntu install java 8 11

Rate this article

Leave a Reply

avatar
  Subscribe  
Notify of