Skip to content

Installing Oracle's JDK on Linux

Toberumono edited this page Aug 24, 2015 · 5 revisions

This guide aims to walk you though installing Oracle's JDK on Linux.

While there are packages that install JDKs available, they are not the official JDK, and, therefore, might have some differences. ##A Few Quick Notes:

  1. This guide does not require sudo (assuming that you already have wget installed. That does require sudo).
  2. This guide assumes that you are comfortable with the following commands:
  3. cd
  4. Nothing else, actually - this guide is kinda short.
  5. This guide uses the following programs:
  6. A modern shell (The thing that Terminal uses)
  7. wget * If you do not have it, sudo apt-get install wget or sudo yum install wget should do the trick.
  8. That's it.
  9. The JDK will be installed in a folder called .jvm in your home directory.
    Use ls -lh $HOME/.jvm to see what is in it.

##Walkthrough

  1. Download the appropriate version of the JDK from Oracle's website, here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
  • The appropriate version has two properties:
    1. It's extension is .tar.gz
    2. It matches your Operating System's bitness (64-bit or 32-bit)
    • To find that out, open terminal and run: uname -m.
      If you see a 64 in the output, download the x64 one.
      Otherwise, download the x86 one.
  1. Open Terminal and cd into the directory in which you downloaded the JDK.

  2. Run this command:

    bash <(wget -qO - https://raw.githubusercontent.com/Toberumono/Miscellaneous/master/java/sudoless_install.sh)
  3. Restart Terminal.

  4. All done! If you want to see the details of what the script does, check out the, Excessive Detail section below.

##Excessive Detail This section contains extra details that aren't important to the Walkthrough, or, well, any part of this page, really, but might be interesting at some level.

###How is the command in step 3 so short? Actually, that command just downloads another script that is stored in this repository. You can check it out here: https://github.com/Toberumono/Miscellaneous/blob/master/java/sudoless_install.sh

###Okay, what does that script do? This script really just boils down to executing the commands needed to perform the installation.

  1. Creates the directory $HOME/.jvm
  2. Determines the newest file in the directory in which it was run that starts with "jdk"
  3. Tells the user which archive it will be using, and gives the user the option to cancel the script
  • If they cancel it, the script exits with an error, and does nothing else.
  1. Unpacks the tarball (the downloaded file) into the $HOME/.jvm directory
  2. Creates a symlink called "current" in the same folder that points to the versioned directory containing the JDK
  3. Calls the append_paths.sh script. (Also from this repo)
  4. That's it.

###Okay, what does the append_paths.sh script do? This script just adds the necessary export commands the user's appropriate shell profile file.
Specifically, it adds:

  1. export PATH="$HOME/.jvm/current/bin:$PATH"
  2. export MANPATH="$HOME/.jvm/current/man:$MANPATH"

It detects the correct profile file and adds the paths using the get_profile.sh and update_rc.sh scripts in the common section of this repository. You can see more information on them here: https://github.com/Toberumono/Miscellaneous/tree/master/common