Install Java on Ubuntu
1. Introduction
Before April 2019, the best way to install Oracle JDK on Ubuntu was to use PPA (Personal Package Archives). One of those options is ppa:webupd8team/java,for example.Its commands automatically download and install Oracle JDK for you. However, Oracle's policy has changed. Whoever wants to download Oracle JDK must log in with an account and accept their terms. So PPAs such as webupd8team/java and so on are no longer working.
Thus, to install Oracle JDK on Ubuntu, you need to manually download the installer, and install it with a few simple commands.
Instead of installing Oracle JDK as in this article, you can install OpenJDK according to the instructions below, both Oracle JDK and OpenJDK are maintained and developed by Oracle.
Note: Oracle has a long-term supporting plan for Java versions 8, 11, and 13; therefore, it is best to use one of these versions.
In this article, I'm going to guide you on how to install Oracle JDK 11, and similarly, you can possibly do with other versions.
First of all, you need to visit the address below to download Oracle JDK:
After that, you get a file:
- jdk-11.0.6_linux-x64_bin.tar.gz
2. Install Java
Use a command to extract the file that you have already downloaded in the previous step.
sudo tar xvzf jdk-11.0.6_linux-x64_bin.tar.gz
# Create directory
sudo mkdir /usr/local/java
After extracting the file, you receive a folder. Next, move that folder to /usr/local/java:
# Move "jdk-11.0.6" directory to /usr/local/java/
sudo mv jdk-11.0.6 /usr/local/java/
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk-11.0.6/bin/javac" 1
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk-11.0.6/bin/java" 1
# If you Install Java 8:
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk-11.0.6/bin/javaws" 1
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
# If you install Java 8:
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/local/java/jdk-11.0.6
sudo update-alternatives --config java
Lastly, see what your installation result is:
java -version
Java Basic
- Customize java compiler processing your Annotation (Annotation Processing Tool)
- Java Programming for team using Eclipse and SVN
- Java WeakReference Tutorial with Examples
- Java PhantomReference Tutorial with Examples
- Java Compression and Decompression Tutorial with Examples
- Configuring Eclipse to use the JDK instead of JRE
- Java String.format() and printf() methods
- Syntax and new features in Java 8
- Java Regular Expressions Tutorial with Examples
- Java Multithreading Programming Tutorial with Examples
- JDBC Driver Libraries for different types of database in Java
- Java JDBC Tutorial with Examples
- Get the values of the columns automatically increment when Insert a record using JDBC
- Java Stream Tutorial with Examples
- Java Functional Interface Tutorial with Examples
- Introduction to the Raspberry Pi
- Java Predicate Tutorial with Examples
- Abstract class and Interface in Java
- Access modifiers in Java
- Java Enums Tutorial with Examples
- Java Annotations Tutorial with Examples
- Comparing and Sorting in Java
- Java String, StringBuffer and StringBuilder Tutorial with Examples
- Java Exception Handling Tutorial with Examples
- Java Generics Tutorial with Examples
- Manipulating files and directories in Java
- Java BiPredicate Tutorial with Examples
- Java Consumer Tutorial with Examples
- Java BiConsumer Tutorial with Examples
- What is needed to get started with Java?
- History of Java and the difference between Oracle JDK and OpenJDK
- Install Java on Windows
- Install Java on Ubuntu
- Install OpenJDK on Ubuntu
- Install Eclipse
- Install Eclipse on Ubuntu
- Quick Learning Java for beginners
- History of bits and bytes in computer science
- Data Types in java
- Bitwise Operations
- if else statement in java
- Switch Statement in Java
- Loops in Java
- Arrays in Java
- JDK Javadoc in CHM format
- Inheritance and polymorphism in Java
- Java Function Tutorial with Examples
- Java BiFunction Tutorial with Examples
- Example of Java encoding and decoding using Apache Base64
- Java Reflection Tutorial with Examples
- Java remote method invocation - Java RMI Tutorial with Examples
- Java Socket Programming Tutorial with Examples
- Which Platform Should You Choose for Developing Java Desktop Applications?
- Java Commons IO Tutorial with Examples
- Java Commons Email Tutorial with Examples
- Java Commons Logging Tutorial with Examples
- Understanding Java System.identityHashCode, Object.hashCode and Object.equals
- Java SoftReference Tutorial with Examples
- Java Supplier Tutorial with Examples
- Java Aspect Oriented Programming with AspectJ (AOP)
Show More
- Java Servlet/Jsp Tutorials
- Java Collections Framework Tutorials
- Java API for HTML & XML
- Java IO Tutorials
- Java Date Time Tutorials
- Spring Boot Tutorials
- Maven Tutorials
- Gradle Tutorials
- Java Web Services Tutorials
- Java SWT Tutorials
- JavaFX Tutorials
- Java Oracle ADF Tutorials
- Struts2 Framework Tutorials
- Spring Cloud Tutorials