JDK-8226904 : current working directory wrong running jpackage app
  • Type: Bug
  • Component: tools
  • Sub-Component: jpackage
  • Affected Version: internal
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-06-27
  • Updated: 2020-12-09
  • Resolved: 2019-06-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
internalFixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
When running an app created by jpackage, the current working directory is set to the "app" directory.

confirmed building simple app-image from app with the following source:
import java.io.*;


public class pwd {
    public static void main (String[] args) {
        try {
            String current = new java.io.File( "." ).getCanonicalPath();
            System.out.println("Current dir:"+current);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

It would be expected that an app run from a command line should have the current working directory of the shell that invoked it.


Comments
Other than just removing the above line, many automated unit tests need to be modified because they expect the output of the packaged app to be in the "app" dir of the packaged app, instead of the current directory the app is run in.
28-06-2019

this is because main.cpp calls: platform.SetCurrentDirectory(package.GetPackageAppDirectory()); not sure why this was ever put in here.
27-06-2019