Error while trying to package custom image with javapackager in java 9-ea?

I'm trying to use java 9-ea (jdk-9 + 180) and the new javapackager to build my own image from a simple module, but I'm getting a nullpointer exception. Does anyone know if I'm too early, or if I'm not using the correct command switches to get it working? Jlink command works fine but javapackager doesn't. I am using the latest jdk-9 + 180 at the time of writing. I've tried both with keys -native exe

and -native image

, but the same type of error occurs. I also tried this on my Mac by creating my own dmg using a switch -native dmg

, but the same error on this platform. I am actually using javapackager here to be able to bind the assembly in exe/dmg

.

Edit 1: I posted a bug report and can now be seen at the following url: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8186661

My module-info.java:

module my.module {
    requires javafx.graphics;
    requires javafx.fxml;
    exports sample;
}

      

First I create a jar with javapackager which works great:

C:\Java9Test\target>javapackager -createjar -appclass sample.Main -srcdir classes -outdir . -outfile myjar -v

I have verified that the resulting jar structure looks ok with correctly compiled module-info.class

and two other classes in it.

The following jlink command works and creates a thumbnail image at runtime:

C:\Java9Test\target>jlink --output release\MyTestApp --compress=2 --module-path "myjar.jar;C:\Program Files\Java\jdk-9\jmods" --add-modules my.module

However, trying to run the following command to build a custom image using javapackager fails:

C:\Java9Test\target>javapackager -deploy -v -outdir packages -name MyTestApp -native image --module-path "myjar.jar;C:\Program Files\Java\jdk-9\jmods" --add-modules my.module --module my.module/sample.Main

outputs:

Running [C:\Program Files\Java\jdk-9\bin\java.exe, -version] Creating app bundle: MyTestApp in C:\Java9Test\target\packages Exception: java.lang.NullPointerException Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "Windows Application Image" (windows.app) failed to produce a bundle. at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:374) at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348) at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)

Edit 2:

Output from flag -native exe

(on Windows)

Running [C:\Program Files\Java\jdk-9\bin\java.exe, -version] Running [C:\Program Files (x86)\Inno Setup 5\iscc.exe, /?] Detected [C:\Program Files (x86)\Inno Setup 5\iscc.exe] version [5] At least one type of shortcut is required. Enabling menu shortcut. Exception: java.lang.NullPointerException Config files are saved to C:\Users\Username\AppData\Local\Temp\fxbundler17330843784617821035\windows. Use them to customize package. Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "EXE Installer" (exe) failed to produce a bundle. at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:374) at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348) at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)

Edit 3:

Log out of the flag -native dmg

(on MacOSX)

Building DMG package for MyTestApp Exception: java.lang.NullPointerException Config files are saved to /var/folders/qs/nk3vxsx90q9_pbjs0ypg74r40000gn/T/fxbundler3765252041328710759/macosx. Use them to customize package. Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "DMG Installer" (dmg) failed to produce a bundle. at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:374) at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348) at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)

Output from flag -native deb

(in Linux Mint)

Running [dpkg-deb, --version] Debian packages should specify a license. The absence of a license will cause some linux distributions to complain about the quality of the application. Exception: java.lang.NullPointerException Config files are saved to /tmp/fxbundler2941553392593775128/linux. Use them to customize package. Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "DEB Installer" (deb) failed to produce a bundle. at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:374) at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348) at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)

Leaving the flag -native rpm

(in Linux Mint)

Running [rpmbuild, --version] At least one type of shortcut is required. Enabling menu shortcut. Exception: java.lang.NullPointerException Config files are saved to /tmp/fxbundler2278571164448075269/linux. Use them to customize package. Exception in thread "main" com.sun.javafx.tools.packager.PackagerException: Error: Bundler "RPM Bundle" (rpm) failed to produce a bundle. at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:374) at jdk.packager/com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:348) at jdk.packager/com.sun.javafx.tools.packager.Main.main(Main.java:496)

+3


source to share


1 answer


Answering my own question here (after getting an answer to the error message):

It turns out that the module path should only contain directory names, not file names, so you cannot specify jar in the path like you can with the jlink command. Javapackager works with modular path if set to compiled modular classes as shown below, also you don't need to enter the module path in the jmods directory because it is automatically picked up.

C:\Java9Test\target>javapackager -deploy -v -outdir packages -name MyTestApp -native image --module-path C:\Java9Test\target\classes --module my.module/sample.Main



However, the resulting build executable MyTestApp.exe

did not work for me, nothing happened when called (double click). Also the assembly is quite cumbersome and it looks like you can't use flags yet --compress=2

and --strip-debug

, as you can, with jlink

. However, I found that you can actually replace the contents of the runtime folder created with javapackager with the jlink command, which gives a much smaller assembly and MyTestApp.exe

works when called! I could also remove java.exe

and javaw.exe

from the replaced runtime\bin

folders, as well msvcp120.dll

, and msvcr120.dll

from the main MyTestApp

-papki as these dll: s are already in the MyTestApp\runtime\bin

folder.

MyTestApp

- folder structure:

folder-structure...

+3


source







All Articles