How to install Oracle Java on openSUSE 12.1

Due to a Oracle license change, openSUSE 12.1 no longer includes Oracle Java (formerly known as Sun Java), only openJDK.  While this should mostly work, it may be that you need the “original” Java for some applications that are picky about it.  This article covers:

  • installing Oracle Java JRE or JDK
  • configuring the java plugin in Firefox
  • binfmt_misc (so you can run java executables by calling them directly on the command line)

Installing Oracle Java JRE or JDK

Get version 7 or 6 here: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Choose the rpm binary that’s suitable for your computer’s architecture (x86 32 bit or x86_64; look in this file to be sure: /etc/SuSE-release)

Open a terminal window (Konsole or Gnome Terminal), become root and install with this command:

sh jdk-6u29-linux-x64-rpm.bin

This will unpack the .rpms from the .bin file and install them.  Verify by running:

java -version
which java

Then you can remove the sun*.rpm files that were created in the current directory.

Configuring the Java plugin for Firefox

As root, go to the browser plugin directory /usr/lib64/browser-plugins (or /usr/lib/browser-plugins for 32 bit).  Then create a symlink to the libnpjp2.so file.  The command below will find the file and create the link to it.  It assumes you have only one version of Oracle Java installed.  If you have more, you have to run the find command first, then create the symlink after you see the results.

cd /usr/lib64/browser-plugins
ln -s $(find /usr/java -name libnpjp2.so)

Verify that it works by starting Firefox and typing “about:plugins” in the Location Bar.  There should be a Java Plugin section in the page.

binfmt_misc

This is a bit optional, being rarely used, but you might like it.  It allows you to run java programs by calling them directly on the command line.  That is, instead of running “java -jar some.jar”, you could run “./some.jar”.  Not a big deal.  However, you may still want to perform at least the first step below because Oracle Java installs an init script called jexec that is not conforming to LSB and you get this kind of errors when enabling other services:

insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:'  entry: please add even if empty.

As root, disable this service and then, erase the script

chkconfig --del jexec
rm -f /etc/init.d/jexec

Then install a proper script from SUSE, if you need the functionality:

zypper install java-binfmt-misc

How to temporarily disable the screen saver in KDE while watching long Flash clips in a web-browser

If you’re watch something on YouTube that’s long-ish, the screen saver is kicking in every few minutes.  So you have to move the mouse around from time to time; that’s annoying.

Here is a one liner for KDE that will simulate user activity every minute.  While this is running in Konsole, the screen saver won’t activate.  You end it with [Ctrl+C].  It’s rather crude, but simple, easy to understand and it does the job.

while /bin/true; do qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity > /dev/null; sleep 1m; done