Installing and Configuring JDK

Rumman Ansari   Software Engineer   2022-03-02   7977 Share
☰ Table of Contents

Table of Content:


Installing from a Package on Linux

Step 1 : Become root.

If you're using an RPM-based Linux system (such as SuSE or RedHat), you can install the Java Development Kit from an RPM package. Make sure you've downloaded the You'll need to su to root (su root) so that you have the correct permission to install the package.

  • The file you downloaded should end with ".rpm"

  • This method assumes you know how to use basic Unix shell commands.

Step 2 : Remove earlier JDK package installations.

  • rpm -e

Step 3 : Install the new package.

You'll be using the "rpm" command again, but this time with different flags:

  • rpm -ivh jdk-7u-linux-x64.rpm (replace "jdk-7u-linux-x64.rpm" with the actual package name)

Step 4 : Delete the .rpm file.

When the package is finished installing, you'll be returned to the command line. If you want to conserve disk space, you can delete the downloaded package file with the

rm command.

Installing from an Archive on Linux or Solaris

Step 1 : Open a terminal window.

If you downloaded an archived tarball of the JDK (it ends with *.tar.gz), use this method to complete the installation.

  • This method assumes you know how to use basic Unix shell commands.

  • If you downloaded a .rpm package file instead of a tarball, see Installing the JDK from a Package on Linux.

After downloading the Java Software Development Kit installer, double-click the downloaded file in the Downloads window of your web browser or in Finder.

Step 2 : Navigate to the directory where you'd like to install the JDK.

JDK in any directory for which you have "write" permissions. Note that only the root user can install the JDK to a system directory.

Step 3 : Move the *.tar.gz file to your current directory.

Use the mv command to get the archive file into the correct directory.

Step 4 : Unzip and install the JDK.

The command is different depending on your operating system (and in the case of Solaris, the processor type). Once installed, a new directory called "jdk” will be created in the current directory. In these examples, replace the name of the *.tar.gz file with the name of the one you downloaded.[13]

  • Linux: tar zxvf jdk-7u-linux-i586.tar.gz
  • Solaris (SPARC): tar xf -
  • Solaris (x64/EM64T): tar xf -

Step 5 : Delete the *.tar.gz file.

Use the rm command to delete the archive file if you want to conserve disk space.