From e4012e2e8651eb62b3b6e95379c45ae74902caea Mon Sep 17 00:00:00 2001 From: Nobuyuki Tsuchimura Date: Fri, 19 Jun 2026 14:11:18 +0900 Subject: [PATCH 1/2] Fix association problem in Windows --- .../app/platform/WindowsPlatform.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/app/src/processing/app/platform/WindowsPlatform.java b/app/src/processing/app/platform/WindowsPlatform.java index 3ec8941a9..b0322919a 100644 --- a/app/src/processing/app/platform/WindowsPlatform.java +++ b/app/src/processing/app/platform/WindowsPlatform.java @@ -111,8 +111,29 @@ boolean register() throws UnsupportedEncodingException { // { Base.CONTRIB_BUNDLE_EXT, "Processing Contribution Bundle" } // }; - static final String REG_APP_DIR = - System.getProperty("user.dir").replace('/', '\\'); + static boolean exeFileExists(File folder) { + File exeFile = new File(folder, APP_NAME.toLowerCase() + ".exe"); + return exeFile.exists(); + } + + static String getRegAppDir() { + try { + // Get the JAR file containing this class (WindowsPlatform) + File jarFile = new File(WindowsPlatform.class.getProtectionDomain(). + getCodeSource().getLocation().toURI()); + // Get the JAR folder ("app" in the standard jpackage layout) + File jarDir = jarFile.getParentFile(); + // Get the processing.exe folder (parent of "app" in the standard layout) + File exeDir = jarDir.getParentFile(); + + if (exeFileExists(exeDir)) return exeDir.getAbsolutePath(); // standard folder layout + if (exeFileExists(jarDir)) return jarDir.getAbsolutePath(); // fallback if exe is inside "app" + } catch (java.net.URISyntaxException e) { + } + return System.getProperty("user.dir"); + } + + static final String REG_APP_DIR = getRegAppDir().replace('/', '\\'); static final String REG_OPEN_COMMAND = REG_APP_DIR + "\\" + APP_NAME.toLowerCase() + ".exe \"%1\""; static final String[] APP_SCHEMES = { "pde" }; // use pde:// From 1d71bbc1999959b7c4fbdfbba5303cf03db7bfbd Mon Sep 17 00:00:00 2001 From: Nobuyuki Tsuchimura Date: Fri, 19 Jun 2026 14:39:37 +0900 Subject: [PATCH 2/2] Fix comment --- app/src/processing/app/platform/WindowsPlatform.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/processing/app/platform/WindowsPlatform.java b/app/src/processing/app/platform/WindowsPlatform.java index b0322919a..b5b1100b0 100644 --- a/app/src/processing/app/platform/WindowsPlatform.java +++ b/app/src/processing/app/platform/WindowsPlatform.java @@ -127,10 +127,10 @@ static String getRegAppDir() { File exeDir = jarDir.getParentFile(); if (exeFileExists(exeDir)) return exeDir.getAbsolutePath(); // standard folder layout - if (exeFileExists(jarDir)) return jarDir.getAbsolutePath(); // fallback if exe is inside "app" + if (exeFileExists(jarDir)) return jarDir.getAbsolutePath(); // if exe and jar is in same folder } catch (java.net.URISyntaxException e) { } - return System.getProperty("user.dir"); + return System.getProperty("user.dir"); // processing.exe not found } static final String REG_APP_DIR = getRegAppDir().replace('/', '\\');