Science and technology

A greater answer to Java SE 11 eradicating JNLP

Recently, I wrote about how we solved the problem of Java 11 eradicating the Java Network Launching Protocol (JNLP), which was how a company I work with distributed a crucial enterprise app. Because I preserve the previous JNLP software on Linux however deploy to Windows desktops, so far as I may inform, that meant I needed to perform a packaging step, which entails making a customized Java 11 runtime surroundings on an intermediate Windows laptop.

The course of regarded like this:

The intermediate machine requirement was a ache; it meant I wanted to hold two machines (not simple to handle once I’m on the street), or I wanted to put in a Windows digital machine on my Linux laptop computer (not one thing I intend to do), or I wanted distant entry to a Windows desktop (the answer we ultimately selected).

Alan Bateman over at Oracle very kindly wrote to me to share a fourth various: Put the Windows model of OpenJDK 11 on the Linux improvement platform and construct the customized Java 11 runtime from that. According to Alan, this has been attainable since JDK 9; he notes that “there are a few limitations and the versions [between the Linux utilities and the Windows OpenJDK] need to match.”

Since this may remove an onerous step outlined above, together with the necessity to have distant entry to the Windows desktop, I needed to examine additional. To my shock and delight, I used to be not a type of “few limitations” Alan talked about—the method works simply superb for me. However, I did uncover that the model of OpenJDK 11 in my Linux distro’s repositories was not “close enough” to the Windows OpenJDK 11 that I downloaded, so I additionally wanted to acquire the identical model of the Linux OpenJDK 11 and use its instruments to create the Java 11 runtime.

The new answer

Here’s my new recipe intimately:

  1. Create a mission folder someplace helpful.
    • I created mine in /residence/me/src/MyOpenJDK11Mission (sorta) and set a Bash surroundings variable known as MYPROJ_HOME (sorta).
  2. Get the matching Windows and Linux OpenJDK 11 packages from AdoptOpenJDK.
  3. Install each of them someplace helpful (the Windows model is a .zip; the Linux, a tarball).
    • I put in mine in $MYPROJ_HOME/home windows and $MYPROJ_HOME/linux, respectively.
  4. Write a Bash script (or a makefile, or an Ant bundle step, or…) to do the packaging.

The key parts of my Bash script answer, which should run contained in the dist folder created by NetBeans, are:

export MYPROJ_HOME=/residence/me/src/MyOpenJDK11Mission
export W64_JAVA_HOME=$MYPROJ_HOME/home windows/jdk-11.zero.2+9
export JAVA_HOME=$MYPROJ_HOME/linux/jdk-11.zero.2+9
export PATH=$JAVA_HOME/bin:$PATH
export DEPS=`jdeps --print-module-deps MyApplication.jar lib/*`
jlink --module-path $W64_JAVA_HOME/jmods --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules $DEPS --output java-runtime

This leaves the customized Java 11 runtime within the dist folder, in a subfolder known as java-runtime. To that folder, my Bash script provides the varied Windows .cmd information for putting in and working the applying, that are after all additionally stored within the MYPROJ_HOME folder. Finally, my Bash script zips up the finished dist folder and makes use of scp to place it on the internet server.

The consequence

How effectively does it work? First and most significantly, the customers do not see any distinction. From my perspective, this answer is a large win, simplifying the packaging course of significantly and eliminating the necessity for an intermediate Windows machine for the packaging course of. And although I miss the coolness of JNLP, I really favor this answer because it retains me in charge of the Java runtime in addition to the applying itself, which is a win for all of us—customers, sysadmins, and me.

With that, I am going to repeat my due to Alan Bateman for sharing this glorious suggestion.

Most Popular

To Top