Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8186661

Javapackager throws NullPointerException creating native image for simple java 9 module

XMLWordPrintable

    • x86
    • other

      FULL PRODUCT VERSION :
      java version "9"
      Java(TM) SE Runtime Environment (build 9+180)
      Java HotSpot(TM) 64-Bit Server VM (build 9+180, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 8.1 (x64)
      Linux Mint 18 "Sarah" - Cinnamon (64-bit)
      MacOSX (Sierra)

      A DESCRIPTION OF THE PROBLEM :
      According to this page http://openjdk.java.net/jeps/275 the javapackager should now have the --module and --module-path switches. However, I get a nullpointer when trying to build a simple HelloWorld-module with the javapackager. The very same error occurs on MacOSX and Linux as well as Windows. A native runtime image can be produced with the jlink command but fails with the javapackager.

      REGRESSION. Last worked in version 9

      ADDITIONAL REGRESSION INFORMATION:
      java version "9"
      Java(TM) SE Runtime Environment (build 9+180)
      Java HotSpot(TM) 64-Bit Server VM (build 9+180, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a simple com.example.Main-class. Create a module-info.java with the content i.e.

      module helloworld.module {
          exports com.example;
      }

      2. Create a jar with the compiled class and a META-INF/MANIFEST.MF folder/file with the following:
      Manifest-Version: 1.0
      Main-Class: com.example.Main

      3. Run the javapackager with the jar-file in module-path:
      >javapackager -deploy -v -outdir release -name HelloWorldJava9 -native image --module-path "HelloWorldJava9.jar;C:\Program Files\Java\jdk-9\jmods" --module helloworld.module/com.example.Main


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected result is that a native runtime image is created from the module.
      ACTUAL -
      C:\HelloWorldJava9\target>javapackager -deploy -v -outdir release -name HelloWorldJava9 -native image --module-path "HelloWorldJava9.jar;C:\Program Files\Java\jdk-9\jmods" --module helloworld.module/com.example.Main
      Running [C:\Program Files\Java\jdk-9\bin\java.exe, -version]
      Creating app bundle: HelloWorldJava9 in C:\HelloWorldJava9\target\release
      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)

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      same with the --add-modules switch:

      C:\HelloWorldJava9\target>javapackager -deploy -v -outdir release -name HelloWorldJava9 -native image --module-path "HelloWorldJava9.jar;C:\Program Files\Java\jdk-9\jmods" --add-modules helloworld.module --module helloworld.module/com.example.Main
      Running [C:\Program Files\Java\jdk-9\bin\java.exe, -version]
      Creating app bundle: HelloWorldJava9 in C:\HelloWorldJava9\target\release
      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)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Main.java:

      package com.example;

      public class Main {

          public static void main(String[] args) {
              System.out.println("Hello World!");
          }
      }

      module-info.java:

      module helloworld.module {
          exports com.example;
      }

      META-INF/MANIFEST.MF:

      Manifest-Version: 1.0
      Main-Class: com.example.Main
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      I can use jlink for now but later on I would like to package the app in exe/dmg/deb/rpm using the javapackager.

      This works:

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

            cbensen Chris Bensen (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: