-
Notifications
You must be signed in to change notification settings - Fork 230
Updating the bundled JRE
The GNU/Linux, MacOS, and Windows versions of Protégé are bundled with a Java Runtime Environment (JRE) so that the application is directly usable “out of the box“ without requiring users to explicitly install such a JRE on their systems. This page explains how to update the bundled JRE whenever needed.
JREs for GNU/Linux, MacOS, and Windows are to be provided as Maven artefacts, under a groupId
of edu.stanford.protege
and a artifactId
of jre.linux
, jre.os-x
, and jre.win
, in a custom Maven repository hosted at https://github.com/protegeproject/mvn-repo.git
.
When building Protégé, and more precisely the protege-desktop
project, those artefacts are fetched by Maven and their contents are included in the packages created by the Maven Assembly plugin.
Preparing the GNU/Linux and Windows JREs is simply a matter of repackaging.
- Obtain a JRE targeting the desired operating system and the x86_64 architecture, e.g. from Adoptium.
- Unpack the archive.
- Move the contents of the archive (which should include directories such as
bin
,lib
,include
) to a directory namedjre
. - Create a JAR archive out of that
jre
directory, namedjre.linux-$VERSION.jar
orjre.win-$VERSION.jar
(where$VERSION
is the version of the JRE – with any+
sign that may occur within it replaced by a_
).
For example, for the GNU/Linux JRE 11.0.23+9 from Adoptium:
$ curl -L -O https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.23+9/OpenJDKU11-jre_x64_linux_hotspot_11.0.23_9.tar.gz
$ tar xf OpenJDKU11-jre_x64_linux_hotspot_11.0.23_9.tar.gz
$ mv jdk-11.0.23+9-jre jre
$ jar --create --file jre.linux-11.0.23_9.jar jre
Preparing the JRE targeting MacOS is more complicated as we need a “universal” variant of the JRE – that is, a JRE made of binaries that can be run natively both on x86_64 and arm64 Mac computers. Neither Adoptium nor any other JRE makers (as far as we know) provide such universal JREs, so we need to build our own, by combining a x86_64 JRE and a arm64 JRE together. You may refer to this blog post for more details.
Roughly, the procedure is:
- Make sure you have the Xcode Command Line Tools installed; you need especially the
lipo
tool. - Obtain both a x86_64 and a arm64 JRE for MacOS (same version, from the same provider).
- Unpack both JREs side by side.
- Iterate over each file in the arm64 JRE:
- if the file is a Mach-O binary file, use the
lipo
tool to combine it with the equivalent file from the x86_64 JRE; - otherwise, just keep the file as it is.
- if the file is a Mach-O binary file, use the
- Place all the files resulting from the previous step under a
jre
directory, mimicking the original directory hierarchy. - Create a JAR archive out of that
jre
directory, namedjre.os-x-$VERSION.jar
.
The procedure is error-prone and therefore you should not attempt to do it by hand. Instead, use a script such as the one shown in the aforementioned blog post.
Now that the JRE packages are ready, they need to be added to the https://github.com/protegeproject/mvn-repo.git
repository.
Clone that repository somewhere on your machine. We’ll assume it is cloned under $MVNREPO.
Use the Maven Install plugin to install each of the JRE packages to the cloned repository. For example, for the GNU/Linux JRE and assuming that the package prepared above is available in the current directory:
$ mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file \
-Dfile=jre.linux-11.0.23_9.jar \
-Dpackaging=jar \
-DlocalRepositoryPath=$MVNREPO/releases \
-DcreateChecksum=true \
-DgroupId=edu.stanford.protege \
-DartifactId=jre.linux \
-Dversion=11.0.23_9
(Note that we are explicitly using an old version of the Maven Install plugin, as more recent versions no longer support the createChecksum
option.)
Repeat the procedure for the jre.os-x
and jre.win
packages, then commit the changes in the mvn-repo
repository and make a pull request to have your changes merged upstream.
Once the online mvn-repo
repository has been updated, you can update the protege-desktop/pom.xml
file to make sure the jre.*
dependencies point to the latest versions of the JRE packages. For example for the GNU/Linux JRE:
<dependency>
<groupId>edu.stanford.protege</groupId>
<artifactId>jre.linux</artifactId>
<version>11.0.23_9</version>
<scope>runtime</scope>
</dependency>
Similarly update the jre.os-x
and jre.win
dependencies, then build Protégé as normal.