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 inJDK-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 atJDK-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 inJDK-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
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
I suspect that this behaviour is caused by the modification done at
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
>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
- relates to
-
JDK-8226904 current working directory wrong running jpackage app
- Resolved
-
JDK-8240571 [macos] the working directory is unexpectedly set to the system root folder
- Closed
-
JDK-8306974 [macos] Current working directory wrong when running jpackage app
- Closed
-
JDK-8308349 missing working directory option for launcher when invoked from shortcuts
- Open