Friday, July 13, 2018

How to install JDK on linux and how it really works?

How to install JDK on linux and how it really works?

You may , well, ask me the question - which installation file should you download for your Linux. You know, you have many options: prm or deb or tar.gz


What is difference between rpm and deb file formats?

  • RPM and DEB files files provide an easy way for software to be distributed, installed, upgraded, and removed 
  • tag.gz is g-zipped tar file. You should download it if you are going to install JDK manually.

What is difference between deb and rpm file formats?

To be honest, therey are both archive files, with some metadata. In order to install deb file you need dpkg - this is package manager for Debian-based systems like Ubuntu, Debian etc. For rpm file format we use RPM Package Manager.

What about dependency problem?

Everything seems great but sometimes we have dependency problems.  In the other words, we had better install all dependencies for our program to work correctly.  Therefor RPM and dpkg  is unable to automatically do it.   Fortunately we have many tools in order to sole the problem:

  • APT (the Advanced Packaging Tool) to install, update and remove software  on Debian-based systems. 
  • YUM  package-management utility that uses the RPM Package Manager.
  • Zypper this is my favorite  package manager for installing, updating and removing packages as well as for managing repositories.  

How To install RPM format JDK on linux?


This method is suitable for SUSE/Arch/Fedora/CentOS/RedHat etc. You should just have RPM package manager.
 

  •  Download oracle jdk RPM package
  • To install using terminal type: `rpm -ivh {jdk-name-version}.rpm`
  • Run the following commands
update-alternatives --install /usr/bin/java java /usr/java/latest/bin/java 100
update-alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 100
view raw update_java_path.sh hosted with ❤ by GitHub
  • Set default Java for in system

update-alternatives --config java
update-alternatives --config javac
view raw default_java.sh hosted with ❤ by GitHub



  

How to install  tar.gz format zypped JDK on linux?


  •  Download oracle jdk tar.gz
  •  mkdir /opt/jdk
  •  tar -zxf {jdk-name-version}.tar.gz -C /opt/jdk
  • update-alternatives --install /usr/bin/java java /opt/jdk/{jdk-name-version}/bin/java 100
  • update-alternatives --install /usr/bin/javac javac /opt/jdk/{jdk-name-version}/bin/javac 100
Check if java is installed

  •  update-alternatives --display java
  •  update-alternatives --display javac
 Set default Java for in System
  •  update-alternatives --config java
  •  update-alternatives --config javac


No comments:

Post a Comment