# Install Oracle JDK on openSUSE

*2014-07-20*

> Install Oracle JDK 8 on openSUSE from an RPM package, configure the default Java tools with update-alternatives, and set JAVA_HOME.

I preferred Oracle's JDK over [OpenJDK](https://openjdk.org/) for my openSUSE development setup. Here's how I installed and configured Oracle JDK 8.

The examples below use JDK 8u5. If you install a different release, adjust the package filenames and installation paths accordingly.

1. **Download the JDK.**

   Download the RPM package for your architecture from [Oracle's JDK 8 archive](https://www.oracle.com/java/technologies/javase/javase8-archive-downloads.html). I used the **Linux x64** package for 64-bit openSUSE. For a 32-bit system, choose the **Linux x86 (i586)** RPM.

2. **Install the RPM.**

   Open a terminal, become root, and change to the directory where you downloaded the RPM package.

   For a 64-bit system, run:

   ```sh
   rpm -i jdk-8u5-linux-x64.rpm
   ```

   For a 32-bit system, run:

   ```sh
   rpm -i jdk-8u5-linux-i586.rpm
   ```

3. **Make Oracle JDK the default.**

   While still working as root, register the JDK tools with `update-alternatives`:

   ```sh
   update-alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_05/bin/java 1551
   update-alternatives --install /usr/bin/javadoc javadoc /usr/java/jdk1.8.0_05/bin/javadoc 1551
   update-alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_05/bin/jar 1551
   update-alternatives --install /usr/bin/javap javap /usr/java/jdk1.8.0_05/bin/javap 1551
   update-alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_05/bin/javac 1551
   update-alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0_05/bin/javaws 1551
   update-alternatives --install /usr/bin/javah javah /usr/java/jdk1.8.0_05/bin/javah 1551
   update-alternatives --install /usr/bin/jarsigner jarsigner /usr/java/jdk1.8.0_05/bin/jarsigner 1551
   ```

   Select the Oracle installation for each registered tool using `update-alternatives --config`. For example, for Java and its compiler:

   ```sh
   update-alternatives --config java
   update-alternatives --config javac
   ```

   Repeat this for the other tools listed above.

4. **Set the JAVA_HOME environment variable.**

   Type `exit` to leave the root shell and return to your regular user account. Open `~/.bashrc` in your preferred text editor and add:

   ```sh
   export JAVA_HOME=/usr/java/jdk1.8.0_05
   ```

   Save the file, then load the updated settings:

   ```sh
   source ~/.bashrc
   ```

5. **Verify the installation.**

   Check the Java runtime and compiler versions:

   ```sh
   java -version
   javac -version
   ```

   Both should report the version you installed. For the JDK 8u5 example, `java -version` should include `java version "1.8.0_05"`.

