How to Install the Java (JDK) in OpenSUSE

How to Install the real Java (JDK) in OpenSUSE

(Tested Working in OpenSUSE Tumbleweed)

The problem of installing openjdk in opensuse when you think you installed openjdk but when you do a javac -version or call javac from commandline it just doesnt work

Well if you think of quickly installing openjdk 8 with zypper like this in commandline is gonna be enough:

# zypper se java-1_8_0-openjdk

Your actually just installing the JRE despite the name of the package which is likely to confuse anyone not familiar with opensuse, as it did me earlier, in defense of opensuse though, you can see why this is a problem is if you do a search with zypper and pay close attention to the packages and their corresponding summary definitions

# zypper se opendjk

Loading repository data...
Reading installed packages...

S | Name                                  | Summary                                                          | Type 
  | java-1_7_0-openjdk                    | SUSE's implementation of the OpenJDK 7 runtime environment       | package                    <- (the Summary states its just the JRE7)
  | java-1_7_0-openjdk-accessibility      | Accessibility connector for OpenJDK 7                            | package
  | java-1_7_0-openjdk-bootstrap          | SUSE's implementation of the OpenJDK 7 runtime environment       | package
  | java-1_7_0-openjdk-bootstrap-devel    | SUSE's implementation of the OpenJDK 7 Development Environment   | package
  | java-1_7_0-openjdk-bootstrap-headless | OpenJDK 7 runtime environment without X, audio and video support | package
  | java-1_7_0-openjdk-demo               | OpenJDK 7 Demos                                                  | package
  | java-1_7_0-openjdk-devel              | SUSE's implementation of the OpenJDK 7 Development Environment   | package           <- (openJDK 7)
  | java-1_7_0-openjdk-headless           | OpenJDK 7 runtime environment without X, audio and video support | package
  | java-1_7_0-openjdk-javadoc            | OpenJDK 7 API Documentation                                      | package
  | java-1_7_0-openjdk-plugin             | Java Web Start and plugin implementation                         | package
  | java-1_7_0-openjdk-src                | OpenJDK 7 Source Bundle                                          | package
  | java-1_8_0-openjdk                    | OpenJDK 8 Runtime Environment                                    | package                                   <- (the Summary states its just the JRE8)*
  | java-1_8_0-openjdk-accessibility      | OpenJDK 8 accessibility connector                                | package
  | java-1_8_0-openjdk-demo               | OpenJDK 8 Demos                                                  | package
  | java-1_8_0-openjdk-devel              | OpenJDK 8 Development Environment                                | package                            <- (And this is the the true openJDK 8)*
  | java-1_8_0-openjdk-headless           | OpenJDK 8 Runtime Environment                                    | package
  | java-1_8_0-openjdk-javadoc            | OpenJDK 8 API Documentation                                      | package
  | java-1_8_0-openjdk-plugin             | Java Web Start and plugin implementation                         | package
  | java-1_8_0-openjdk-src                | OpenJDK 8 Source Bundle                                          | package
  | java-1_9_0-openjdk                    | OpenJDK Runtime Environment                                      | package                                   <- (the Summary states its just the JRE9)
  | java-1_9_0-openjdk-accessibility      | OpenJDK accessibility connector                                  | package
  | java-1_9_0-openjdk-demo               | OpenJDK Demos                                                    | package
  | java-1_9_0-openjdk-devel              | OpenJDK Development Environment                                  | package                            <-(openJDK 9)
  | java-1_9_0-openjdk-headless           | OpenJDK Runtime Environment                                      | package
  | java-1_9_0-openjdk-javadoc            | OpenJDK API Documentation                                        | package
  | java-1_9_0-openjdk-src                | OpenJDK Source Bundle                                            | package

So if you want to install the openjdk and develop java apps with it, you have to install the openjdk-devel package with the version you want to use, in this example its openjdk 8:

# zypper in java-1_8_0-openjdk-devel

now you can try: java -version and javac -version , and get output like this, whereas you would have gotten the cnf command not found if you tried javac -version if you installed just java-1_8_0-openjdk , as its just the JRE , anyways as with other java installs there is no need to install the JRE version as installing the openjdk-devel the true openjdk package in opensuse, already contains a JRE so you can just do the following commands

$ java -version
openjdk version "1.8.0_101"
OpenJDK Runtime Environment (IcedTea 3.1.0) (suse-1.1-x86_64)
OpenJDK 64-Bit Server VM (build 25.101-b13, mixed mode)

$ javac -version
javac 1.8.0_101

- Nevertheless the naming convention of the package is still confusing, especially for people new to opensuse, they should just rename the openjdk JRE to openJRE or something, so even on quick glance its self explanatory

Resource Links:

Tumbleweed Android Studio and Java JDK Thread in the OpenSUSE Forum
Trying to get Android Studio to start but I'm getting an error saying JAVA_HOME points to a jre not a jdk, a...
Others have complained of the confusing package naming of opensuse like in this blog: - A Quick Review of OpenSUSE Tumbleweed! (2015)
an excerpt from this blog
"My only MAJOR complaint is the package naming and development packages. It’s FRUSTRATING hunting down each package, truly a nightmare compared to other distributions."

NOTE: However if you have multiple implementations of Java, when you want to select your preferred java implementation or switch to the one you prefer.

Select which multiple implementations of JRE and JDK and even Java Web Browser Plug-in installed then you can select which one to use with the update-alternatives commands below:

Java application launcher (JRE)
# /usr/sbin/update-alternatives --config java

Java compiler (JDK)
# /usr/sbin/update-alternatives --config javac

Java Web Browser (Web browser plug-in)
# /usr/sbin/update-alternatives --config javaplugin


Post a Comment