how to install java on ubuntu 18.0.4

‮ual.www‬tturi.com
how to install java on ubuntu 18.0.4

To install the Java Development Kit (JDK) on Ubuntu 18.04, you can follow these steps:

  1. Add the Oracle Java PPA (personal package archive) to your system's package sources. This will allow you to install Oracle Java using apt-get. To add the PPA, run the following command:
sudo add-apt-repository ppa:webupd8team/java
  1. Update the package index to include the packages from the Oracle Java PPA:
sudo apt-get update
  1. Install Oracle Java 8 using apt-get. To install the JDK, run the following command:
sudo apt-get install oracle-java8-installer
  1. Set Oracle Java 8 as the default Java runtime. To set Oracle Java as the default, run the following command:
sudo update-java-alternatives -s java-8-oracle
  1. Verify that Oracle Java 8 is installed and set as the default by running the following command:
java -version

This command should print the version number of Oracle Java 8.

Keep in mind that Oracle Java 8 is no longer supported by Oracle, and it is recommended to use a newer version of Java, such as Java 11 or Java 15. To install a newer version of Java, you can follow the same steps as above, but replace java-8-oracle with the appropriate version number.

You can also install OpenJDK, the open-source version of Java, using apt-get. To install OpenJDK 8, run the following command:

sudo apt-get install openjdk-8-jdk

To set OpenJDK 8 as the default Java runtime, run the following command:

sudo update-java-alternatives -s java-1.8.0-openjdk-amd64

To verify that OpenJDK 8 is installed and set as the default, run the java -version command. This command should print the version number of OpenJDK 8.

Created Time:2017-11-01 20:42:56  Author:lautturi