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

Jpackage "--resources-dir" flag does not do anything on Mac

    XMLWordPrintable

Details

    • x86
    • os_x

    Description

      ADDITIONAL SYSTEM INFORMATION :
      System:
      Mac OS Mojave (MacBook Pro 11.5)
      Version 10.14.6

      Problem has been confirmed with OpenJDK 11.0.2 & OpenJFX 11.0.2 with both jpackage from JDK 14 ea and JDK 15 ea, and also with OpenJDK 14 ea & OpenJFX 14 ea.

      EITHER:

      openjdk version "11.0.2" 2019-01-15
      OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
      OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
      &
      OpenJFX 11.0.2 jmods from gluon
      &
      jpackage from 14-ea 2020-03-17 or openjdk 15-ea 2020-09-15

      ----
      OR:

      openjdk 14-ea 2020-03-17
      OpenJDK Runtime Environment (build 14-ea+32-1423)
      OpenJDK 64-Bit Server VM (build 14-ea+32-1423, mixed mode, sharing)
      &
      OpenJFX jmods 14 build 7 downloaded 10th Jan 2020.

      A DESCRIPTION OF THE PROBLEM :
      Custom resources do not get added to the app image on Mac OS X when using the --resources-dir flag. According to the documentation, this flag should be used when wanting to override the resources directory.

      REGRESSION : Last worked in version 14

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a simple JavaFX project or use the example class provided, let's call it Main.java. Compile with javac providing path to OpenJFX mods in the --module-path and module javafx.controls with --add-modules.
      2. Create jar: jar cfe myjar/Main.jar Main Main.class
      3. Using jlink, create a custom JRE called myjre, including path to JFX in the --module-path and javafx.controls in the modules with --add-modules.
      4. Create a directory ./myresources and add some file into it, such as a picture of your cat, cat.jpg.
      5. Using jpackage from ea JDK 15, package the application:

      jpackage --type app-image -n "My App" --main-class Main --main-jar Main.jar --runtime-image myjre --input myjar --resource-dir myresources --java-options "-verbose:class"

      6. App image runs fine. However, inspecting the contents of the package, notice that the custom resources added with the --resource-dir flag didn't do anything. There is no cat.jpg in the Resources dir or anywhere else in the app contents.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Directory Contents/Resources in the app contents should contain custom resources from the resources directory provided with the --resources-dir flag. According to documentation, the flag is used for the following: "Path to override jpackage resources Icons, template files, and other resources of jpackage can be over-ridden by adding replacement resources to this directory. (absolute path or relative to the current directory)"
      ACTUAL -
      Nothing happens. The Contents/Resources dir only contains the default icon, indicating that the directory wasn't overriden. My guess is that it is getting overwritten again when the icon is set.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class Main extends Application {

          @Override
          public void start(Stage stage) {
              String javaVersion = System.getProperty("java.version");
              String javafxVersion = System.getProperty("javafx.version");
              Label l = new Label("JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
              Scene scene = new Scene(new StackPane(l), 640, 480);
              stage.setScene(scene);
              stage.show();
          }

          public static void main(String[] args) {
              launch();
          }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None known.

      FREQUENCY : always


      Attachments

        1. Main.java
          0.7 kB
          Pardeep Sharma

        Activity

          People

            almatvee Alexander Matveev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: