Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Tutorials»How to Install OpenJDK JAVA 11/8 in Ubuntu and Debian

    How to Install OpenJDK JAVA 11/8 in Ubuntu and Debian

    By RahulNovember 8, 20172 Mins ReadUpdated:October 9, 2019

    This tutorial will help to install JAVA (OpenJDK) on all versions of Ubuntu, Debian, and LinuxMint systems. You can also use this tutorial to install Java on any Debian based systems. Let’s follow the below simple steps for the installation.

    Advertisement
    • Install Oracle JAVA 8 on Ubuntu & LinuxMint
    • Install Oracle JAVA 9 on Ubuntu & LinuxMint

    Step 1 – Search OpenJDK Packages

    OpenJDK packages are available under native apt repositories. You can simply use apt-cache search command to search the available java version for your Ubuntu system.

    apt-cache search openjdk
    

    As per above output, you can see openjdk-11-* and openjdk-8-* is available in the package manager.

    Step 2 – Install JAVA (OpenJDK)

    Use the below command to install OpenJDK on your Debian based systems using the package manager from the default repository. The below commands will install Java Development Kit (JDK) and Java Runtime Environment (JRE) both on your system. You can install JRE package only to setup Runtime Environment only.

    OpenJDK 11

    sudo apt-get install openjdk-11-jre openjdk-11-jdk
    

    OpenJDK 8

    sudo apt-get install openjdk-8-jre openjdk-8-jdk
    

    Step 3 – Configure Default Java Version

    After installation of Java uses below command to verify the installed version of Java on your system.

    java -version
    
    openjdk version "11.0.4" 2019-07-16 LTS
    OpenJDK Runtime Environment 18.9 (build 11.0.4+11-LTS)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.4+11-LTS, mixed mode, sharing)
    

    Step 4 – Set JAVA_HOME

    Its the best practice to set Java environment variable after installing java. To setup JAVA_HOME add following line to /etc/environment file, Path may be differ with your system architecture.

    echo "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/" >> /etc/environment
    source /etc/environment
    

    Use the following command to check the environment value

    echo $JAVA_HOME
    
    /usr/lib/jvm/java-11-openjdk-amd64/
    

    install java Java java8 java9 openjdk
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    An Introduction to the “./configure” Command: Compiling Source Code in Linux

    Getting Started with Linux Command line: The Beginning

    Backing Up Your Linux System with Rsync: A Step-by-Step Guide

    View 7 Comments

    7 Comments

    1. Gleepgloop on February 3, 2020 9:08 am

      What if apt-cache search openjdk doesn’t show any results for openjdk-11?

      Reply
    2. Swapnil on January 21, 2020 9:37 am

      Quite nice and simple.
      Thanks

      Reply
    3. Marco Gomez on July 28, 2018 12:06 am

      Thank you for the information.

      I’m a Debian user, and this command “update-alternatives –config java” instead “Step 4” work fine for me, always as root user.

      I hope my comment can help some one.

      Sorry my english, I’m novice.

      Reply
      • Rahul K. on July 31, 2018 5:24 am

        Thanks Gomez

        Reply
    4. Kiwon Cho on July 3, 2018 4:03 am

      Thanks! very helpful.
      Really needed some briej introducton installing openjdk!

      Reply
    5. google on June 20, 2018 6:49 am

      not bad

      Reply
    6. rochdi on January 9, 2018 7:48 am

      Thanks

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Error: EACCES: permission denied, scandir (Resolved)
    • How To Install Python 3.11 on Ubuntu 22.04 / 20.04
    • How to Install Python 3.11 on Amazon Linux 2
    • An Introduction to the “./configure” Command: Compiling Source Code in Linux
    • How to Install PHP 8.x on Pop!_OS
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.