Java is a very popular Object-Oriented General programming language. Java can be used for Desktop Software application development, Web Application development, Mobile Application development, Embedded Systems Development. It is a very versatile language due to it being built on the “Write Once Run Anywhere” Principle. Any Java program once compiled can be executed on any system having a Java Virtual Machine (JVM).

In this article we are going to learn how to install the Java JDK and JRE in Ubuntu (A popular distribution of Linux).

Before going further, we should clear the differences between java JRE, JDK, Oracle JDK and Open JDK.

  • JRE (Java Runtime Environment) is required to run Java programs and applications. This is for end-user consumers that don’t program in Java.
  • JDK (Java Development Kit) is required for software development in the Java Programming language.
  • OpenJDK is the open-source equivalent of Java Development Kit while Oracle JDK is the official Development kit that require payment for commercial use. OpenJDK is adequate for basic java development but Android Studio using Java as the primary programming language recommends OracleJDK for development.

Check Current Java Installation

We first need to check if we have Java installed in our system, we can do so by running the following command on the terminal.

If it gives the following result than java is not installed in the system.

If it gives the following result:

This means that the OpenJDK JRE and Java Development Kit are installed in the system.

We can remove the OpenJDK JRE and Java Development Kit using the following command:

Install OpenJDK Java Runtime Environment

We can install the OpenJDK JRE (Java Runtime Environment) by using the following command:

This will install the latest available JRE. We can install a specific version of the JRE by using ‘openjdk-8-jre’ or ‘openjdk-7-jre’ in place of ‘deafult-jre’.

Install OpenJDK Java Development Kit

We can install the OpenJDK Java Development Kit by using the following command:

This command will install the latest version of the OpenJDK Java Development Kit available.

In order to download a specific version, we need to use ‘openjdk-8-jdk or ‘openjdk-7-jdk’ in place of ‘default-jdk’.

Install Oracle Java Development Kit

We can install the Oracle Java Development Kit from a Linux Personal Package Archive (PPA).

Type the following commands into the terminal and press enter:

The update will take a couple of minutes depending on your internet connection.

After it is completed, run the following commands to install java.

You can replace 12 with 10,8, 7 etc. Depending on the java version you want to install.

After the installation is completed run the following command to see the installation:

 ‘Jdk-12.0.2’ is our Oracle Java Development Kit.

Copy the following lines in the ‘/etc/profile’ file.

Change the ‘jdk-12.0.2’ depending on your java version installation.

You can now use java. Use the following command to see your java installation.

How do I run Java on Linux?

How to compile and run Java program in Linux / Ubuntu Terminal
  1. Install Java software development kit. sudo apt-get install openjdk-8-jdk.
  2. write your program. you can write your program using any text editor.
  3. Now, compile your program javac HelloWorld.
  4. Finally, run your program.

How do I get Java on Ubuntu?

The easiest option for installing Java is to use the version packaged with Ubuntu. By default, Ubuntu 18.04 includes OpenJDK version 11, which is an open-source variant of the JRE and JDK. To install this version, first update the package index: sudo apt update.

Does Linux come with Java?

There are many Linux distributions available and many of them come with one or more Java platform/s pre-installed. In the vast majority of the cases the Java platform which comes pre-installed on a Linux machine is not the official Oracle Java, but another one such as OpenJKD or IBM Java.

How do I know where Java is installed on Linux?

  1. Check if JAVA_HOME is already set , Open Console.
  2. Make sure you have installed Java already.
  3. Execute: vi ~/.bashrc OR vi ~/.bash_profile.
  4. add line : export JAVA_HOME=/usr/java/jre1.8.0_04.
  5. save the file.
  6. source ~/.bashrc OR source ~/.bash_profile.
  7. Execute : echo $JAVA_HOME.
  8. Output should print the path.

How do I install Java?

Download and Install
  1. Go to the Manual download page.
  2. Click on Windows Online.
  3. The File Download dialog box appears prompting you to run or save the download file. To run the installer, click Run. To save the file for later installation, click Save. Choose the folder location and save the file to your local system.

How do I install Java 11 on Linux?

Installing the 64-Bit JDK 11 on Linux Platforms
  1. Download the required file: For Linux x64 systems: jdk11. interim.
  2. Change the directory to the location where you want to install the JDK, then move the . tar.
  3. Unpack the tarball and install the downloaded JDK: $ tar zxvf jdk11.
  4. Delete the . tar.

How do I install Java 1.8 on Linux?

Installing Open JDK 8 on Debian or Ubuntu Systems
  1. Check which version of the JDK your system is using: java -version.
  2. Update the repositories:
  3. Install OpenJDK:
  4. Verify the version of the JDK:
  5. If the correct version of Java is not being used, use the alternatives command to switch it:
  6. Verify the version of the JDK:

How do I install Java 1.7 on Linux?

Change to the directory in which you want to install.
  1. Change to the directory in which you want to install. Type: cd directory_path_name.
  2. Move the . tar. gz archive binary to the current directory.
  3. Unpack the tarball and install Java. tar zxvf jre-8u73-linux-x64.tar.gz.
  4. Delete the . tar.

Is Java 1.8 the same as Java 8?

javac -source 1.8 (is an alias for javac -source 8 ) java.

What OpenJDK 11?

JDK 11 is the open-source reference implementation of version 11 of the Java SE Platform as specified by by JSR 384 in the Java Community Process. JDK 11 reached General Availability on 25 September 2018.

How do I check my version of Java?

Java Version in Windows Programs
  1. Click the Start button.
  2. Scroll through the applications and programs listed until you see the Java folder.
  3. Click on the Java folder, then About Java to see the Java version.

Which is latest version of Java?

The latest version of Java is Java 16 or JDK 16 released on March, 16th 2021 (follow this article to check Java version on your computer).

Does Windows 10 need Java?

You only need Java if an app requires it. The app will prompt you. So, yes, you can uninstall it and it’s likely safer if you do.

How do I change my Java version?

In the Java Control Panel, click on the Java tab. Verify that the latest Java Runtime version is enabled by checking the Enabled box. Click OK in Java Control Panel window to confirm changes and close the window. Try to run same applet and verify it is now running using latest version of Java installed in your system.

How do I open Java settings?

Right-click on the Start button and select the Control Panel option. In the Windows Control Panel, click on Programs. Click on the Java icon to open the Java Control Panel.

Can we install two versions of Java?

It is very possible to run multiple versions of Java on the same machine so you can run your existing applications and Ignition at the same time.

Is it safe to install Java?

The legitimate java plug-in is safe to install, but some websites use fake pop-up windows to trick you into downloading software that isn’t actually java. The legitimate java plug-in is safe to install, but some websites use fake pop-up windows to trick you into downloading software that isn’t actually java.