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

[macos]:jpackage's working directory is different from javapackager

XMLWordPrintable

    • x86_64
    • os_x

      ADDITIONAL SYSTEM INFORMATION :
      MacBookPro16,2/ macOS 10.15.7
      jpackage: AdoptOpenJDK 15.0.1
      javapackager: Amazon Corretto8.275.01.1

      A DESCRIPTION OF THE PROBLEM :
      As reported in JDK-8240571, I had also expected the working directory to be <application name>/Contents/app from the analogy of the result of javapackager.
      I suspect that this behaviour is caused by the modification done at JDK-8226904.
      This behaviour may not be a bug, however, I hope that jpackage will work as javapackager.

      Andy Herrick added a comment - 2019-06-27 11:37 in JDK-8226904
      >this is because main.cpp calls:
      > platform.SetCurrentDirectory(package.GetPackageAppDirectory());
      >
      > not sure why this was ever put in here.

      https://bugs.openjdk.java.net/browse/JDK-8240571
      https://bugs.openjdk.java.net/browse/JDK-8226904


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      **** for jpackage
      $ mkdir target
      $ /Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home/bin/javac PwdFrame.java
      $ /Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home/bin/jar -cf target/pwd.jar PwdFrame.class
      $ /Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home/bin/jpackage --type app-image -i target --main-class PwdFrame --name pwd_jpackage --main-jar pwd.jar
      $ open ./pwd_jpackage.app


      **** for javapackager
      $ mkdir target result
      $ /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home/bin/javac PwdFrame.java
      $ echo 'Main-Class: PwdFrame'| cat > MANIFEST.MF
      $ /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home/bin/jar -cmvf MANIFEST.MF target/pwd8.jar PwdFrame.class
      $ /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home/bin/javapackager -deploy -native image -outdir result -outfile PwdFrame -name pwd_javapackager -appclass PwdFrame -srcdir target -srcfiles pwd8.jar
      $ open ./result/bundles/pwd_javapackager.app


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      * jpackage
      Current dir:/private/tmp/test/result/bundles/pwd_jpackage.app/Contents/app

      ACTUAL -
      * jpackage
      Current dir:/

      * javapackager
      Current dir:/private/tmp/test/result/bundles/pwd_javapackager.app/Contents/Java

      ---------- BEGIN SOURCE ----------
      // PwdFrame.java
      //
      import javax.swing.*;

      public class PwdFrame {
          public static void main(String[] args) {
      try{
                  String current = new java.io.File( "." ).getCanonicalPath();
      JFrame f = new JFrame("PwdFrame");
      JTextArea t = new JTextArea("Current dir:"+current);
      f.add(t);
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      f.setSize(500, 400);
      f.setVisible(true);
      } catch (Exception e){}
          }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


            adev Anupam Dev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: