I'm using the Oracle “Self-Contained Application Packaging” tool to make a .deb
file for a JavaFX 8 desktop application. The generated package file can be installed without problems on Ubuntu but then the application fails to run. The file is installed as follows:
$ sudo dpkg -i vocabhunter-1.0.14.deb
However, attempting to run the application generates the following error:
$ /opt/VocabHunter/VocabHunter
VocabHunter Failed to locate JNI_CreateJavaVM
VocabHunter Failed to launch JVM
Importantly, I'm generating a bundle without the JRE included and on investigation it seems that the problem relates to this. The generated file /opt/VocabHunter/app/VocabHunter.cfg
contains the following line:
app.runtime=
If I edit this and add the path to Java, the program launches without problems. As a workaround, I've suggested that after installing the .deb
bundle the user run the following command:
sudo sed -i "s|app.runtime=.*|app.runtime=$JAVA_HOME|g" /opt/VocabHunter/app/VocabHunter.cfg
However, this makes things hard for the user. Does anyone know how to fix the configuration for the JavaFX packaging tool to avoid this problem?
The build uses Gradle to call an Ant script to generate the bundle. Gradle fills in all of the necessary variables. The Ant script is as follows:
<project name="VocabHunter Packaging" basedir=""
xmlns:fx="javafx:com.sun.javafx.tools.ant">
<property environment="env"/>
<property name="JAVA_HOME" value="${env.JAVA_HOME}"/>
<target name="jfxbundle" description="Build the application bundle">
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant"
classpath="${JAVA_HOME}/lib/ant-javafx.jar"/>
<fx:deploy outdir="${basedir}/build"
nativeBundles="${packageType}">
<fx:platform basedir=""/>
<fx:application id="VocabHunterId"
name="VocabHunter"
mainClass="${mainClass}"
version="${version}"/>
<fx:resources>
<fx:fileset dir="${basedir}/build/libs"/>
</fx:resources>
<fx:info title="VocabHunter">
<fx:association description="VocabHunter session"
extension="wordy"
mimetype="application/x-vnd.VocabHunterSession"
icon="${sessionIcon}"/>
</fx:info>
<fx:bundleArgument arg="icon"
value="${appIcon}"/>
<fx:bundleArgument arg="mac.CFBundleVersion"
value="${version}"/>
<fx:bundleArgument arg="launcher-cfg-format"
value="prop"/>
</fx:deploy>
</target>
</project>
You can see the full script in context here.
I'm testing this using JDK 1.8.0_92 on Ubuntu 14.04.