◐ Shell
clean mode source ↗

Fix REG_APP_DIR to support jpackage application launchers by tutimura-kg · Pull Request #1528 · processing/processing4

Description

This PR fixes an issue where the file association fails when Processing is packaged and launched using jpackage.

Currently, REG_APP_DIR relies directly on System.getProperty("user.dir"). However, when launched via a jpackage generated launcher, user.dir points to the directory from which the application was invoked (e.g., the current terminal directory or shortcut location), rather than the actual installation directory of processing.exe. This causes incorrect registry paths to be registered in checkAssociations().

Thus, launching via file association breaks the next launch via file association. And launching via shortcut fixes the file association. This has not surfaced as a major issue on Windows 11 because the File Manager can override registry-defined associations. However, it remains a hidden bug that this PR aims to fix.

Changes

  • Updated REG_APP_DIR to dynamically resolve the installation directory based on the location of the JAR file (via WindowsPlatform.class).
  • Added a fallback to the original user.dir behavior in case processing.exe cannot be found relative to the JAR location.
  • Kept the changes minimal to avoid any unexpected impact on the existing codebase.

This ensures that file associations (.pde, etc.) always register the correct absolute path of processing.exe, regardless of the working directory at launch.