Install Java Development Kit

From Bonus Bits
Jump to: navigation, search

Purpose

This article gives the steps to install Java Development Kit on various operating systems.


Ubuntu

Install Oracle Java 7 (JDK_&_JRE) on Ubuntu


Mac

List Current Version

java -version

Install Latest Version

  1. Download x86 and/or x64 JDK
    1. Java 7 SDK
      1. http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
    2. Java 8 SDK
      1. http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  2. Run installer

List Current Home Setting

/usr/libexec/java_home

Set Java Home Version

This should be completed by the installer, but it's a good idea to double check it was set. Also, this is how you can switch between versions if needed.

/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home -v 1.8.0_121 --exec javac -version

Set Environment Variables

java_version=1.8.0_121
export IDEA_JDK=$(/usr/libexec/java_home -v $java_version)
export RUBYMINE_JDK=$(/usr/libexec/java_home -v $java_version)
export JDK_HOME=$(/usr/libexec/java_home -v $java_version)
export JAVA_HOME=$(/usr/libexec/java_home -v $java_version)

Uninstall Older JDK Versions

  1. View all installed versions
    ls /Library/Java/JavaVirtualMachines
    
  2. Remove all but latest and macOS installed version
    sudo rm -rf /Library/Java/JavaVirtualMachines/1.6.0.jdk
    
    sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk
    
    sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk
    
    sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk
    


Windows

  1. Download x86 and/or x64 JDK
    1. Java 7 SDK
      1. http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
    2. Java 8 SDK
      1. http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  2. Run installer