How to install java 8 JRE & JDK?

Hi guys. I cant seem to find a guide to install both Java 8 JRE & JDK in OpenSuse 42.1.

Please advise me and point me to one.

Thanks,

you cn install openjdk 1.8 (or 8.0) from the standard oss repo’s (it should already be installed) by executing

zypper in java-1_8_0-openjdk

to get oracle’s jave go to
https://www.java.com/en/download/linux_manual.jsp
and select the 64bit rpm or click this
http://javadl.sun.com/webapps/download/AutoDL?BundleId=111740
then open a terminal in the download folder install that rpm with zypper

zypper in jre-8u66-linux-x64.rpm

Is installing enough? I used to be configure it after install when I was in Fedora 23. And what about JDK?

you need to use update-alternatives in order to select/set the default java run-time, even tho it’s called openjdk it’s not a development toolkit it’s a run-time, I do believe there is gui in kde’s config center just not sure if it was kde4’s or plasma 5’s as I don’t really use java I only keep the one that came with the OS.

edit
just remembered the KDE GUI was an extra package I played around with a few months ago it’s for KDE4
https://software.opensuse.org/package/kalternatives

sorry didn’t see your jdk question
well for installing the jdk is more or less the same
install the java-1_8_0-openjdk-devel packages which carry the compiler and libraries

zypper in java-1_8_0-openjdk-devel

for Oracle’s version go here and download the 64bit rpm
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
or click this
http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-x64.rpm
then install it with zypper

zypper in jdk-8u66-linux-x64.rpm

again use update-alternatives to set the preferred java compiler

I installed JRE and JDK. I also installed kalternative but I dont know how to run it?

I tried update-alternatives but it seems that it cant see the Java 8 new install.

arkan:/home/ahmed # update-alternatives --all
There is only one alternative in link group alternate-install-present (providing /usr/lib/nvidia/alternate-install-present): /usr/lib/nvidia/alternate-install-present-default
Nothing to configure.

There is only one alternative in link group awk (providing /bin/awk): /usr/bin/gawk
Nothing to configure.

There is only one alternative in link group coverage (providing /usr/bin/coverage): /usr/bin/coverage-3.4
Nothing to configure.

There is only one alternative in link group db_archive (providing /usr/bin/db_archive): /usr/bin/db48_archive
Nothing to configure.

There is only one alternative in link group db_checkpoint (providing /usr/bin/db_checkpoint): /usr/bin/db48_checkpoint
Nothing to configure.

There is only one alternative in link group db_deadlock (providing /usr/bin/db_deadlock): /usr/bin/db48_deadlock
Nothing to configure.

There is only one alternative in link group db_dump (providing /usr/bin/db_dump): /usr/bin/db48_dump
Nothing to configure.

There is only one alternative in link group db_hotbackup (providing /usr/bin/db_hotbackup): /usr/bin/db48_hotbackup
Nothing to configure.

There is only one alternative in link group db_load (providing /usr/bin/db_load): /usr/bin/db48_load
Nothing to configure.

There is only one alternative in link group db_printlog (providing /usr/bin/db_printlog): /usr/bin/db48_printlog
Nothing to configure.

There is only one alternative in link group db_recover (providing /usr/bin/db_recover): /usr/bin/db48_recover
Nothing to configure.

There is only one alternative in link group db_sql (providing /usr/bin/db_sql): /usr/bin/db48_sql
Nothing to configure.

There is only one alternative in link group db_stat (providing /usr/bin/db_stat): /usr/bin/db48_stat
Nothing to configure.

There is only one alternative in link group db_upgrade (providing /usr/bin/db_upgrade): /usr/bin/db48_upgrade
Nothing to configure.

There is only one alternative in link group db_verify (providing /usr/bin/db_verify): /usr/bin/db48_verify
Nothing to configure.

There is only one alternative in link group easy_install (providing /usr/bin/easy_install): /usr/bin/easy_install-3.4
Nothing to configure.

There is only one alternative in link group ftp (providing /usr/bin/ftp): /usr/bin/tnftp
Nothing to configure.

There is only one alternative in link group funzip (providing /usr/bin/funzip): /usr/bin/funzip-plain
Nothing to configure.

There is only one alternative in link group gem2rpm (providing /usr/bin/gem2rpm): /usr/bin/gem2rpm.ruby2.1-0.10.1
Nothing to configure.

There is only one alternative in link group gem2rpm-0.10.1 (providing /usr/bin/gem2rpm-0.10.1): /usr/bin/gem2rpm.ruby2.1-0.10.1
Nothing to configure.

There is only one alternative in link group gem2rpm.ruby2.1 (providing /usr/bin/gem2rpm.ruby2.1): /usr/bin/gem2rpm.ruby2.1-0.10.1
Nothing to configure.

There is only one alternative in link group gst-install-plugins-helper (providing /usr/lib/gst-install-plugins-helper): /usr/lib/pk-gstreamer-install
Nothing to configure.

There are 2 choices for the alternative gtk-update-icon-cache (providing /usr/bin/gtk-update-icon-cache).

Selection Path Priority Status

  • 0 /usr/bin/gtk-update-icon-cache-3.0 3 auto mode
    1 /usr/bin/gtk-update-icon-cache-2.0 2 manual mode
    2 /usr/bin/gtk-update-icon-cache-3.0 3 manual mode

Press enter to keep the current choice
[li], or type selection number: 3[/li]There are 2 choices for the alternative gtk-update-icon-cache (providing /usr/bin/gtk-update-icon-cache).

Selection Path Priority Status

  • 0 /usr/bin/gtk-update-icon-cache-3.0 3 auto mode
    1 /usr/bin/gtk-update-icon-cache-2.0 2 manual mode
    2 /usr/bin/gtk-update-icon-cache-3.0 3 manual mode

Press enter to keep the current choice
[li], or type selection number: 0[/li]
There are 2 choices for the alternative icewm (providing /usr/bin/icewm).

Selection Path Priority Status

  • 0 /usr/bin/icewm-default 100 auto mode
    1 /usr/bin/icewm-default 100 manual mode
    2 /usr/bin/icewm-lite 0 manual mode

Press enter to keep the current choice
[li], or type selection number: 0[/li]
There is only one alternative in link group input.svgz (providing /usr/share/plasma/desktoptheme/default/icons/input.svgz): /usr/share/plasma/desktoptheme/default/icons/input.svgz-kdeorg
Nothing to configure.

There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status

  • 0 /usr/lib64/jvm/jre-1.8.0-openjdk/bin/java 1805 auto mode
    1 /usr/lib64/jvm/jre-1.7.0-openjdk/bin/java 1705 manual mode
    2 /usr/lib64/jvm/jre-1.8.0-openjdk/bin/java 1805 manual mode

Press enter to keep the current choice
[li], or type selection number: 0[/li]
There are 2 choices for the alternative javaplugin (providing /usr/lib64/browser-plugins/javaplugin.so).

Selection Path Priority Status

  • 0 /usr/lib64/java-1_8_0-openjdk-plugin/lib/IcedTeaPlugin.so 18020 auto mode
    1 /usr/lib64/java-1_7_0-openjdk-plugin/lib/IcedTeaPlugin.so 17147 manual mode
    2 /usr/lib64/java-1_8_0-openjdk-plugin/lib/IcedTeaPlugin.so 18020 manual mode

Press enter to keep the current choice
[li], or type selection number: 0[/li]
There is only one alternative in link group jre_1.7.0 (providing /usr/lib64/jvm/jre-1.7.0): /usr/lib64/jvm/jre-1.7.0-openjdk
Nothing to configure.

There is only one alternative in link group jre_1.8.0 (providing /usr/lib64/jvm/jre-1.8.0): /usr/lib64/jvm/jre-1.8.0-openjdk
Nothing to configure.

There are 2 choices for the alternative jre_openjdk (providing /usr/lib64/jvm/jre-openjdk).

Selection Path Priority Status

  • 0 /usr/lib64/jvm/jre-1.8.0-openjdk 1805 auto mode
    1 /usr/lib64/jvm/jre-1.7.0-openjdk 1705 manual mode
    2 /usr/lib64/jvm/jre-1.8.0-openjdk 1805 manual mode

Press enter to keep the current choice
[li], or type selection number: 0[/li]
There are 2 choices for the alternative kdesu (providing /usr/bin/kdesu).

Selection Path Priority Status

  • 0 /usr/lib64/libexec/kf5/kdesu 25 auto mode
    1 /usr/lib64/kde4/libexec/kdesu 20 manual mode
    2 /usr/lib64/libexec/kf5/kdesu 25 manual mode

Press enter to keep the current choice
[li], or type selection number: 0[/li]
There is only one alternative in link group keyring (providing /usr/bin/keyring): /usr/bin/keyring-2.7
Nothing to configure.

There is only one alternative in link group ksh (providing /bin/ksh): /bin/ksh93
Nothing to configure.

There is only one alternative in link group ld (providing /usr/bin/ld): /usr/bin/ld.bfd
Nothing to configure.

There is only one alternative in link group libblas.so.3 (providing /usr/lib64/libblas.so.3): /usr/lib64/blas/libblas.so.3
Nothing to configure.

There are 2 choices for the alternative libglx.so (providing /usr/lib64/xorg/modules/extensions/libglx.so).

Selection Path Priority Status

  • 0 /usr/lib64/xorg/modules/extensions/nvidia/nvidia-libglx.so 100 auto mode
    1 /usr/lib64/xorg/modules/extensions/nvidia/nvidia-libglx.so 100 manual mode
    2 /usr/lib64/xorg/modules/extensions/xorg/xorg-libglx.so 50 manual mode

Press enter to keep the current choice
[li], or type selection number: 0[/li]
There is only one alternative in link group liblapack.so.3 (providing /usr/lib64/liblapack.so.3): /usr/lib64/lapack/liblapack.so.3
Nothing to configure.

There is only one alternative in link group lua (providing /usr/bin/lua): /usr/bin/lua5.2
Nothing to configure.

There is only one alternative in link group mount.ntfs (providing /sbin/mount.ntfs): /sbin/mount.ntfs-3g
Nothing to configure.

There is only one alternative in link group netcat (providing /usr/bin/netcat): /usr/bin/nc
Nothing to configure.

There is only one alternative in link group nosetests (providing /usr/bin/nosetests): /usr/bin/nosetests-3.4
Nothing to configure.

There is only one alternative in link group openSUSE-default.xml (providing /usr/share/wallpapers/openSUSE-default.xml): /usr/share/wallpapers/openSUSE-default-static.xml
Nothing to configure.

There is only one alternative in link group pip (providing /usr/bin/pip): /usr/bin/pip3.4
Nothing to configure.

There is only one alternative in link group rake (providing /usr/bin/rake): /usr/bin/rake.ruby.ruby2.1
Nothing to configure.

There is only one alternative in link group rake.ruby2.1 (providing /usr/bin/rake.ruby2.1): /usr/bin/rake.ruby.ruby2.1
Nothing to configure.

There is only one alternative in link group rdoc (providing /usr/bin/rdoc): /usr/bin/rdoc.ruby.ruby2.1
Nothing to configure.

There is only one alternative in link group rdoc.ruby2.1 (providing /usr/bin/rdoc.ruby2.1): /usr/bin/rdoc.ruby.ruby2.1
Nothing to configure.

There is only one alternative in link group ri (providing /usr/bin/ri): /usr/bin/ri.ruby.ruby2.1
Nothing to configure.

There is only one alternative in link group ri.ruby2.1 (providing /usr/bin/ri.ruby2.1): /usr/bin/ri.ruby.ruby2.1
Nothing to configure.

There is only one alternative in link group unzip (providing /usr/bin/unzip): /usr/bin/unzip-plain
Nothing to configure.

There is only one alternative in link group unzipsfx (providing /usr/bin/unzipsfx): /usr/bin/unzipsfx-plain
Nothing to configure.

There is only one alternative in link group vncviewer (providing /usr/bin/vncviewer): /usr/bin/vncviewer-tigervnc
Nothing to configure.

There is only one alternative in link group xml-commons-apis (providing /usr/share/java/xml-commons-apis.jar): /usr/share/java/xerces-j2-xml-apis.jar
Nothing to configure.

There is only one alternative in link group zipgrep (providing /usr/bin/zipgrep): /usr/bin/zipgrep-plain
Nothing to configure.

Please advise me. Thanks,

to use kalternatives you need to use kde4’s settings center for that you need to install kdebase4-workspace-addons

zypper in kdebase4-workspace-addons

then you need to run systemsettings

systemsettings

there should be a menu item called KDE System Settings but plasma5 also has that menu item for running plasma 5 system settings.

the rest of your post is informative, update-alternatives is not used for java only it’s used for a lot of other applications and for most you don’t have an alternative.
I’d say you need to run
for jre

update-alternatives --config java

for jdk

update-alternatives --config javac

The java 8 is not showing in the alternatives list. I need it to be added to show.

arkan:/home/ahmed # update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).      
                                                                             
  Selection    Path                                       Priority   Status  
------------------------------------------------------------                 
* 0            /usr/lib64/jvm/jre-1.8.0-openjdk/bin/java   1805      auto mode
  1            /usr/lib64/jvm/jre-1.7.0-openjdk/bin/java   1705      manual mode
  2            /usr/lib64/jvm/jre-1.8.0-openjdk/bin/java   1805      manual mode                       

Press enter to keep the current choice
[li], or type selection number: 0[/li]arkan:/home/ahmed # update-alternatives --config javac
update-alternatives: error: no alternatives for javac
arkan:/home/ahmed # 

It looks like your update-alternatives is currently set to Java 8 JRE using openjdk ( 1.8.x is Java 8).
javac is a package and binary, so there wouldn’t be an update-alternatives setting it (at most there might have been an update-alternatives setting for the jdk, but that doesn’t seem to be the case for openjdk’s jdk).

So,
Some things to know about the jre and jdk using openjdk…

  • By default when you install the openjdk package, it only installs the jre, you don’t install the jdk.
  • To install the openjdk jdk, you have to install the package openjdk-devel(select specific version for 7 or 8).
  • Once openjdk-devel is installed, although it’s automatically linked to the existing update-alternative options(You won’t see a new separate option), it looks like it’s set regardless of update-alternatives setting (eg if you set to Java 7 jre, you’re still using the Java 8 jdk). I don’t know if that’s an error or not.

Bottom line for your example invoking javac is that it wouldn’t be even expected to be seen in update-alternatives. If it’s installed, it’s accessible without needing any switching.
You should just be able to invoke in a console, eg

javac -help

TSU

The Oracle package doesn’t facilitate ease of use with update-alternatives (you have to manually intervine). You need to use (as root) update-alternatives --install blah blah blah

See man update-alternatives for details about the blah blah blah switches

well I haven’t done java in a long time and that was just for fun (I’m not a coder), the only issue running multiple java virtual machines and compilers are the $PATH and $CLASSPATH environment variables which uses different executeble’s and jar files for different runtimes/compilers
my recommendation is to use 2 or more bash files which will modify your path and classpath
you can try something like this:
for java and javac and cp add these two lines

[FONT=inherit][FONT=&quot]export PATH=/path/to/java/you/want/to/use/bin:$PATH
[FONT=inherit][FONT=inherit][FONT=&quot]export CLASSPATH="[FONT=inherit][FONT=inherit][FONT=&quot]/path/to/java/you/want/to/use/lib/ext[/FONT][/FONT][/FONT] [/FONT][/FONT]
[/FONT][/FONT][/FONT]

use one script to modify your path and classpath to point to openjdk_1.8 and a second to point to Oracle’s java bin folder and the classpath to oracle’s ext folder

A User posted his scripts to install update-alternatives for Oracle 8 JDE (I assume based on the SE RPM, since there is no mention whether he used the RPM or TAR). I have not tried his scripts or reviewed closely what is in the scripts but a superficial skim suggests the scripts might work

https://forums.opensuse.org/showthread.php/512626-Java-8-jdk-and-update-alternatives-on-Leap

If the scripts work,
I may apply the same improvements I contributed for the Oracle SE JDK 7 scripts which can be found in the comments to the SDB and on my github site. I didn’t post Oracle SE 8 JDK 8 scripts because the JDK architecture moving from 7 to 8 radically changed and requires some real work to identify all the components that need to be linked in the newer JDK.

Again… This is strictly for the Oracle 8 JDK download and <does not> apply to the openjdk JDK installed by the OP of this thread.

tSU

  1. Download jdk from Oracle:
    64bit Version: http://download.oracle.com/otn-pub/java/jdk/8u74-b02/jdk-8u74-linux-x64.rpm
    32bit Version:http://download.oracle.com/otn-pub/java/jdk/8u74-b02/jdk-8u74-linux-i586.rpm

  2. Install the JDK by opening a terminal,
    becoming ROOT and switching to the directory where you downloaded the RPM package.

For x64 version execute: rpm -i jdk-8u74-linux-x64.rpm

For 32-bit version execute: rpm -i jdk-8u74-linux-i586.rpm

  1. Make the OracleJDK default system JDK. While at the terminal and with root privileges execute the following sequence of commands:
    a. update-alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_74/bin/java 1551

        b.        update-alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_74/bin/javac 1551
    
        c. (this one is for browser plugin, optional, in openSuse we have IcedTea, as for me redundant step..)                                                                                                                                                      update-alternatives --install /usr/lib/browser-plugins/javaplugin.so javaplugin /usr/java/jdk1.8.0_74/jre/lib/amd64/libnpjp2.so" 1551
    
  2.     a.   update-alternatives --config java
                                                                                    And choose ....           /usr/java/jdk1.8.0_74/bin/java
           
        b.   update-alternatives --config javac
                                                                                   And choose ....           /usr/java/jdk1.8.0_74/bin/javac 
    
      c. (optional, for browser plugin, may break you dependencies, openSuse uses IcedTea by default)
                                                                                                                                                                                         update-alternatives --config javaplugin
    
  3. Type ‘exit‘ at the terminal. As normal user open ~/.bashrc in your favorite command line text editor and add the following lines:

export JAVA_HOME=/usr/java/jdk1.8.0_74
export PATH=$JAVA_HOME/bin:$PATH

save file and then in terminal modify/add :
source ~/.bash_profile