#JavaInspires
Hi Guys,
In this post, we will see how to install java in Ubuntu.
Here we can install either JRE or JDK and Both if required.
Command to Install:
JDK => sudo apt install openjdk-11-jdk-headless
JRE => sudo apt install openjdk-11-jre-headless
Open terminal and run the above command on need.
Log flow as follows:
developer@developer:~$ sudo apt-get update [sudo] password for developer: Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease Hit:2 http://us.archive.ubuntu.com/ubuntu focal InRelease Hit:3 http://security.ubuntu.com/ubuntu focal-security InRelease Hit:4 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease Hit:5 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease Reading package lists... Done developer@developer:~$ java Command 'java' not found, but can be installed with: sudo apt install default-jre # version 2:1.11-72, or sudo apt install openjdk-11-jre-headless # version 11.0.11+9-0ubuntu2~20.04 sudo apt install openjdk-8-jre-headless # version 8u292-b10-0ubuntu1~20.04 sudo apt install openjdk-13-jre-headless # version 13.0.4+8-1~20.04 sudo apt install openjdk-14-jre-headless # version 14.0.2+12-1~20.04 developer@developer:~$ sudo apt install openjdk-11-jre-headless Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: ca-certificates-java java-common Suggested packages: default-jre fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei The following NEW packages will be installed: ca-certificates-java java-common openjdk-11-jre-headless 0 upgraded, 3 newly installed, 0 to remove and 28 not upgraded. Need to get 37.3 MB of archives. After this operation, 171 MB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://us.archive.ubuntu.com/ubuntu focal/main amd64 java-common all 0.72 [6,816 B] Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 openjdk-11-jre-headless amd64 11.0.11+9-0ubuntu2~20.04 [37.2 MB] Get:3 http://us.archive.ubuntu.com/ubuntu focal/main amd64 ca-certificates-java all 20190405ubuntu1 [12.2 kB] Fetched 37.3 MB in 7s (5,169 kB/s) Selecting previously unselected package java-common. (Reading database ... 189880 files and directories currently installed.) Preparing to unpack .../java-common_0.72_all.deb ... Unpacking java-common (0.72) ... Selecting previously unselected package openjdk-11-jre-headless:amd64. Preparing to unpack .../openjdk-11-jre-headless_11.0.11+9-0ubuntu2~20.04_amd64.deb ... Unpacking openjdk-11-jre-headless:amd64 (11.0.11+9-0ubuntu2~20.04) ... Selecting previously unselected package ca-certificates-java. Preparing to unpack .../ca-certificates-java_20190405ubuntu1_all.deb ... Unpacking ca-certificates-java (20190405ubuntu1) ... Setting up java-common (0.72) ... Setting up openjdk-11-jre-headless:amd64 (11.0.11+9-0ubuntu2~20.04) ... update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/java to provide /usr/bin/java (java) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jjs to provide /usr/bin/jjs (jjs) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/keytool to provide /usr/bin/keytool (keytool) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/rmiregistry to provide /usr/bin/rmiregistry (rmiregistry) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/pack200 to provide /usr/bin/pack200 (pack200) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/unpack200 to provide /usr/bin/unpack200 (unpack200) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/lib/jexec to provide /usr/bin/jexec (jexec) in auto mode Setting up ca-certificates-java (20190405ubuntu1) ... head: cannot open '/etc/ssl/certs/java/cacerts' for reading: No such file or directory Adding debian:SwissSign_Silver_CA_-_G2.pem Adding debian:TrustCor_RootCert_CA-2.pem Adding debian:Buypass_Class_2_Root_CA.pem Adding debian:GlobalSign_Root_CA_-_R2.pem Adding debian:XRamp_Global_CA_Root.pem Adding debian:USERTrust_RSA_Certification_Authority.pem Adding debian:DigiCert_Assured_ID_Root_G3.pem Adding debian:SecureTrust_CA.pem Adding debian:Buypass_Class_3_Root_CA.pem Adding debian:COMODO_ECC_Certification_Authority.pem Adding debian:DigiCert_Global_Root_G2.pem Adding debian:emSign_ECC_Root_CA_-_C3.pem Adding debian:UCA_Extended_Validation_Root.pem Adding debian:Network_Solutions_Certificate_Authority.pem Adding debian:QuoVadis_Root_CA_1_G3.pem Adding debian:OISTE_WISeKey_Global_Root_GC_CA.pem Adding debian:Entrust_Root_Certification_Authority_-_EC1.pem Adding debian:Certigna_Root_CA.pem Adding debian:Trustwave_Global_ECC_P384_Certification_Authority.pem Adding debian:Microsec_e-Szigno_Root_CA_2009.pem Adding debian:IdenTrust_Public_Sector_Root_CA_1.pem Adding debian:Microsoft_ECC_Root_Certificate_Authority_2017.pem Adding debian:Autoridad_de_Certificacion_Firmaprofesional_CIF_A62634068.pem Adding debian:AffirmTrust_Commercial.pem Adding debian:USERTrust_ECC_Certification_Authority.pem Adding debian:GDCA_TrustAUTH_R5_ROOT.pem Adding debian:T-TeleSec_GlobalRoot_Class_3.pem Adding debian:E-Tugra_Certification_Authority.pem Adding debian:AffirmTrust_Networking.pem Adding debian:DST_Root_CA_X3.pem Adding debian:GeoTrust_Primary_Certification_Authority_-_G2.pem Adding debian:Staat_der_Nederlanden_Root_CA_-_G3.pem Adding debian:DigiCert_Assured_ID_Root_CA.pem Adding debian:emSign_ECC_Root_CA_-_G3.pem Adding debian:QuoVadis_Root_CA_2.pem Adding debian:certSIGN_Root_CA_G2.pem Adding debian:SZAFIR_ROOT_CA2.pem Adding debian:Microsoft_RSA_Root_Certificate_Authority_2017.pem Adding debian:Actalis_Authentication_Root_CA.pem Adding debian:Baltimore_CyberTrust_Root.pem Adding debian:Hongkong_Post_Root_CA_3.pem Adding debian:AffirmTrust_Premium.pem Adding debian:AC_RAIZ_FNMT-RCM.pem Adding debian:ssl-cert-snakeoil.pem Adding debian:Amazon_Root_CA_2.pem Adding debian:Trustis_FPS_Root_CA.pem Adding debian:SwissSign_Gold_CA_-_G2.pem Adding debian:CFCA_EV_ROOT.pem Adding debian:GlobalSign_ECC_Root_CA_-_R4.pem Adding debian:Hellenic_Academic_and_Research_Institutions_ECC_RootCA_2015.pem Adding debian:Amazon_Root_CA_3.pem Adding debian:QuoVadis_Root_CA_3.pem Adding debian:Global_Chambersign_Root_-_2008.pem Adding debian:T-TeleSec_GlobalRoot_Class_2.pem Adding debian:ISRG_Root_X1.pem Adding debian:Entrust_Root_Certification_Authority_-_G4.pem Adding debian:Starfield_Class_2_CA.pem Adding debian:GlobalSign_Root_CA.pem Adding debian:GTS_Root_R2.pem Adding debian:SSL.com_Root_Certification_Authority_RSA.pem Adding debian:Security_Communication_RootCA2.pem Adding debian:certSIGN_ROOT_CA.pem Adding debian:DigiCert_Trusted_Root_G4.pem Adding debian:NetLock_Arany_=Class_Gold=_FÅ‘tanúsÃtvány.pem Adding debian:OISTE_WISeKey_Global_Root_GB_CA.pem Adding debian:DigiCert_Global_Root_G3.pem Adding debian:DigiCert_High_Assurance_EV_Root_CA.pem Adding debian:GTS_Root_R3.pem Adding debian:SSL.com_Root_Certification_Authority_ECC.pem Adding debian:Atos_TrustedRoot_2011.pem Adding debian:TeliaSonera_Root_CA_v1.pem Adding debian:Staat_der_Nederlanden_EV_Root_CA.pem Adding debian:GTS_Root_R1.pem Adding debian:UCA_Global_G2_Root.pem Adding debian:ePKI_Root_Certification_Authority.pem Adding debian:emSign_Root_CA_-_C1.pem Adding debian:GlobalSign_Root_CA_-_R3.pem Adding debian:Trustwave_Global_Certification_Authority.pem Adding debian:Amazon_Root_CA_4.pem Adding debian:DigiCert_Assured_ID_Root_G2.pem Adding debian:QuoVadis_Root_CA.pem Adding debian:Amazon_Root_CA_1.pem Adding debian:TUBITAK_Kamu_SM_SSL_Kok_Sertifikasi_-_Surum_1.pem Adding debian:SSL.com_EV_Root_Certification_Authority_ECC.pem Adding debian:GlobalSign_Root_CA_-_R6.pem Adding debian:VeriSign_Universal_Root_Certification_Authority.pem Adding debian:D-TRUST_Root_Class_3_CA_2_2009.pem Adding debian:NAVER_Global_Root_Certification_Authority.pem Adding debian:QuoVadis_Root_CA_3_G3.pem Adding debian:Certigna.pem Adding debian:DigiCert_Global_Root_CA.pem Adding debian:Cybertrust_Global_Root.pem Adding debian:Entrust_Root_Certification_Authority_-_G2.pem Adding debian:TWCA_Global_Root_CA.pem Adding debian:COMODO_RSA_Certification_Authority.pem Adding debian:Comodo_AAA_Services_root.pem Adding debian:Starfield_Root_Certificate_Authority_-_G2.pem Adding debian:Certum_Trusted_Network_CA.pem Adding debian:Certum_Trusted_Network_CA_2.pem Adding debian:TrustCor_RootCert_CA-1.pem Adding debian:AffirmTrust_Premium_ECC.pem Adding debian:EC-ACC.pem Adding debian:TrustCor_ECA-1.pem Adding debian:Go_Daddy_Root_Certificate_Authority_-_G2.pem Adding debian:QuoVadis_Root_CA_2_G3.pem Adding debian:e-Szigno_Root_CA_2017.pem Adding debian:Izenpe.com.pem Adding debian:SSL.com_EV_Root_Certification_Authority_RSA_R2.pem Adding debian:IdenTrust_Commercial_Root_CA_1.pem Adding debian:Hellenic_Academic_and_Research_Institutions_RootCA_2011.pem Adding debian:Chambers_of_Commerce_Root_-_2008.pem Adding debian:SecureSign_RootCA11.pem Adding debian:GlobalSign_ECC_Root_CA_-_R5.pem Adding debian:Starfield_Services_Root_Certificate_Authority_-_G2.pem Adding debian:Hongkong_Post_Root_CA_1.pem Adding debian:Entrust.net_Premium_2048_Secure_Server_CA.pem Adding debian:CA_Disig_Root_R2.pem Adding debian:Trustwave_Global_ECC_P256_Certification_Authority.pem Adding debian:Go_Daddy_Class_2_CA.pem Adding debian:TWCA_Root_Certification_Authority.pem Adding debian:COMODO_Certification_Authority.pem Adding debian:Entrust_Root_Certification_Authority.pem Adding debian:Security_Communication_Root_CA.pem Adding debian:D-TRUST_Root_Class_3_CA_2_EV_2009.pem Adding debian:Hellenic_Academic_and_Research_Institutions_RootCA_2015.pem Adding debian:emSign_Root_CA_-_G1.pem Adding debian:Sonera_Class_2_Root_CA.pem Adding debian:Secure_Global_CA.pem Adding debian:ACCVRAIZ1.pem Adding debian:GTS_Root_R4.pem done. Processing triggers for man-db (2.9.1-1) ... Processing triggers for ca-certificates (20210119~20.04.1) ... Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. done. developer@developer:~$ java -version openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04) OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing) developer@developer:~$ developer@developer:~$ java -version openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04) OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing) developer@developer:~$ javac -version Command 'javac' not found, but can be installed with: sudo apt install default-jdk # version 2:1.11-72, or sudo apt install openjdk-11-jdk-headless # version 11.0.11+9-0ubuntu2~20.04 sudo apt install openjdk-8-jdk-headless # version 8u292-b10-0ubuntu1~20.04 sudo apt install openjdk-13-jdk-headless # version 13.0.4+8-1~20.04 sudo apt install openjdk-14-jdk-headless # version 14.0.2+12-1~20.04 sudo apt install ecj # version 3.16.0-1 developer@developer:~$ sudo apt install openjdk-11-jdk-headless Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: openjdk-11-demo openjdk-11-source The following NEW packages will be installed: openjdk-11-jdk-headless 0 upgraded, 1 newly installed, 0 to remove and 28 not upgraded. Need to get 223 MB of archives. After this operation, 233 MB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 openjdk-11-jdk-headless amd64 11.0.11+9-0ubuntu2~20.04 [223 MB] Fetched 223 MB in 42s (5,279 kB/s) Selecting previously unselected package openjdk-11-jdk-headless:amd64. (Reading database ... 190233 files and directories currently installed.) Preparing to unpack .../openjdk-11-jdk-headless_11.0.11+9-0ubuntu2~20.04_amd64.deb ... Unpacking openjdk-11-jdk-headless:amd64 (11.0.11+9-0ubuntu2~20.04) ... Setting up openjdk-11-jdk-headless:amd64 (11.0.11+9-0ubuntu2~20.04) ... update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jar to provide /usr/bin/jar (jar) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jarsigner to provide /usr/bin/jarsigner (jarsigner) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/javac to provide /usr/bin/javac (javac) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/javadoc to provide /usr/bin/javadoc (javadoc) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/javap to provide /usr/bin/javap (javap) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jcmd to provide /usr/bin/jcmd (jcmd) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jdb to provide /usr/bin/jdb (jdb) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jdeprscan to provide /usr/bin/jdeprscan (jdeprscan) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jdeps to provide /usr/bin/jdeps (jdeps) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jfr to provide /usr/bin/jfr (jfr) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jimage to provide /usr/bin/jimage (jimage) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jinfo to provide /usr/bin/jinfo (jinfo) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jlink to provide /usr/bin/jlink (jlink) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jmap to provide /usr/bin/jmap (jmap) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jmod to provide /usr/bin/jmod (jmod) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jps to provide /usr/bin/jps (jps) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jrunscript to provide /usr/bin/jrunscript (jrunscript) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jshell to provide /usr/bin/jshell (jshell) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jstack to provide /usr/bin/jstack (jstack) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jstat to provide /usr/bin/jstat (jstat) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jstatd to provide /usr/bin/jstatd (jstatd) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/rmic to provide /usr/bin/rmic (rmic) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/serialver to provide /usr/bin/serialver (serialver) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jaotc to provide /usr/bin/jaotc (jaotc) in auto mode update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jhsdb to provide /usr/bin/jhsdb (jhsdb) in auto mode developer@developer:~$ developer@developer:~$ java -version openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04) OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing) developer@developer:~$ javac -version javac 11.0.11 developer@developer:~$