How to Install Java 9 on Ubuntu

Java is not included in Ubuntu by default. There are many application that do not work without Java. So, you require to install Java for using other application and developing Java application. You can use Java by installing JRE (Java Runtime Environment) or JDK (Java Development Kit). JRE consists all required libraries, Java Virtual Machine (JVM), plug-ins, and Web Start to run any Java application. JDK consists not only JRE but all necessary tools to compile and debug Java codes. If you want to develop Java application then you have to install JDK. There are two options to install JDK on any operating system. One is OracleJDK (Oracle Java Development Kit) and another is OpenJDK (Open Java Development Kit).

Oracle JDK:

Oracle JDK was known as SUN JDK before and it was the official proprietary implementation of Java language. Now, it is maintain by Oracle team. Many new features are added in the new version of Oracle JDK. Some features are mentioned here.

  • It is available in both free and commercial version and it is under Oracle Binary Code License Agreement.
  • It includes Java plug-ins and Java Web Start.
  • It contains many third-party open-source and commercial components.
  • It is better for developing commercial Java application.

Open JDK:

Open JDK is an open source implementation of Java Standard Edition platform and it can be used as an alternative of Oracle JDK.  Some important features of OpenJDK are mentioned here.

  • It is completely free to use and it is under GPL v2 license.
  • It contains most of the necessary features of Oracle JDK to develop Java application.
  • It has the ability to update JDK packages automatically by using package manager.
  • The source code is improving regularly by the contribution of open source developer.

From the above features, it is clear that you can gain maximum facilities of Java Development Kit by using Open JDK without any cost. How you can install Java 9 using Open JDK on Ubuntu is shown in this tutorial.

Installing Java 9:

First of all, you have to check if any old version of Java is installed on your system or not.

$ java

If the following information appears then Java is not installed before. OpenJDK is the default option of installing Java on Ubuntu.

If any old version of Java is installed on your system then you have to remove it before running the installation command of Java 9. Run the following command to remove previously installed Java package.

$ sudo aptget purge openjdk*

You can install JRE or JDK based on your requirements. First, run the command to install JRE and check it is working or not. The following command will install Java version 9 using JRE package. Press ‘y’ when it will ask for permission to complete the installation process.

$ sudo apt install openjdk9jre

After completing the installation process you can check JRE package is working or not by executing the following command.

$ java version

The output of the command will show the version number of OpenJDK, Java tool for executing java code and OpenJDK VM type which can be 32-bit VM or 64-bit VM depends on your computer configuration.

It is mentioned before that JRE is used for executing Java application only. So if you need Java just for executing any games or other types of applications then the above installation is OK for you. But if you want to use Java for developing Java application then you should install JDK package of OpenJDK. You need to remove JRE, before running the command of installing JDK. The following command will remove JRE from your system

$ sudo apt install openjdk9jre

Run the command to install JDK package of OpenJDK that will install necessary compiling and debugging tools with JRE. Press ‘y’ when it will ask for permission to complete the installation process.

$ sudo apt install openjdk9jdk

Test the package is working properly or not after completing the installation process.

$ java verson

Testing Java:

Write a very simple Java code to test installed Java program. Open a text editor and write the following Java code. Remember to keep the same name for class and file name. Here, class name is ‘FirstJava’. So, the filename will be ‘’.

public class FirstJava {
  public static void main(String[] args){
    System.out.println("This is my first Java program.");

Open the terminal and go to the file location.

Run javac command to compile the code and create class file. If the code compiles successfully then ‘FirstJava.class’file will be generated.

$ javac

Run java command to run the class file.

$ java FirstJava

The output of the program is a simple text, “This is my first Java program”. So, the following output will appear after executing the class file.

If you are planning to use Java in your Ubuntu operating system then try the above tutorial to install Java in your system and use it.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to Install Java 9 on Ubuntu

Java is not included in Ubuntu by default. There are many application that do not work without Java. So, you require to...

How to Install JDK 12 on CentOS 7

Java Development Kit (JDK) is used to develop and test Java applications. It is used by millions of Java developers around...

Install Oracle JDK 11 on Arch Linux

The full form of JDK is Java Development Kit. It is a set of tools used to compile, run, and debug Java applications. JDK...
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh

Mua proxy Onet uy tín tại

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?