Ubuntu 18.04 and Java Web Start

Submitted by Tha-Fox on 2019-10-09

I promised to configure a laptop to a friend of mine, who needed to run one Java-based application on it. Little did I know, what I had promised. My idea was to install Ubuntu 18.04 and OpenJDK and be done with it.

When my plan was implemented in reality and it was time for the first test, I noticed there was only a big white window on the screen. We decided to RTFM and found the instructions. They recommended using Windows XP and Oracle's Java.

I installed Oracle's Java 11 (the latest LTS release for the time being) according to these instructions. Everything went as instructed, but I couldn't do anything to JNLP file the application gave to me. I knew I needed to run it with Java Web Start. Further research revealed that Oracle had deprecated Java WS and my best option was running an older Java release despite the security holes coming with it.

Here's how I got my setup working. If you want to follow along, please note what I said above about old Java releases and their security holes.

The first thing to do is install Oracle JDK, version 8. Here is the download link. As we are using Ubuntu, download the tar.gz file. If you are copy-pasting the commands, please note that you have to modify the paths according to your system, change at least the version number as that will most likely differ from my setup.

Create a directory where to extract Java:

sudo mkdir -p /usr/lib/jvm

Change to the directory:

cd /usr/lib/jvm

Extract the Java to the directory and remember to adjust the paths according to your version of Java:

sudo tar -zxvf ~/Downloads/jdk-8u221-linux-x64.tar.gz

Then the environment variables have to be added so that the system can find the Java:

sudo gedit /etc/enviroment

Add the following bin folders to the existing PATH variable:

/usr/lib/jvm/jdk1.8.0_221/bin:/usr/lib/jvm/jdk1.8.0_221/db/bin:/usr/lib/jvm/jdk1.8.0_221/jre/bin

Note the semicolons that have to separate the paths. Remember to put one between the original and the paths you are appending, too. Once again, modify the paths according to your Java version.

You need to add some other environment variables after the path:

J2SDKDIR="/usr/lib/jvm/jdk1.8.0_201"

J2REDIR="/usr/lib/jvm/jdk1.8.0_201/jre"

JAVA_HOME="/usr/lib/jvm/jdk1.8.0_201"

DERBY_HOME="/usr/lib/jvm/jdk1.8.0_201/db"

When modified, the file should look something like this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_221/bin:/usr/lib/jvm/jdk1.8.0_221/db/bin:/usr/lib/jvm/jdk1.8.0_221/jre/bin"

J2SDKDIR="/usr/lib/jvm/jdk1.8.0_201"

J2REDIR="/usr/lib/jvm/jdk1.8.0_201/jre"

JAVA_HOME="/usr/lib/jvm/jdk1.8.0_201"

DERBY_HOME="/usr/lib/jvm/jdk1.8.0_201/db"

Then we will configure Java locations for Ubuntu:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_221/bin/java" 0

sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_221/bin/javac" 0

sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_221/bin/java

sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_221/bin/javac

Verify that the locations are correct:

update-alternatives --list java

update-alternatives --list javac

Log out, back in and then test that you get the correct Java version with command:

java -version

Once that works, the last step is to get the browser use your just installed Java WS. You should see Java WS binary in:

/usr/lib/jvm/jdk1.8.0_221/bin/javaws

When using Firefox, go to settings and set it to open JNLP files with the javaws binary.

Next time you open a JNLP file in browser, you should see it opening up within Java WS window.

Tagit

Lisää uusi kommentti

Rajattu HTML

  • Sallitut HTML-tagit: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Rivit ja kappaleet päätetään automaattisesti.
  • Verkko- ja sähköpostiosoitteet muutetaan automaattisesti linkeiksi.