diff --git a/compiler/core/src/zserio/tools/ExtensionManager.java b/compiler/core/src/zserio/tools/ExtensionManager.java index 8ad20a5ed..9188cac25 100644 --- a/compiler/core/src/zserio/tools/ExtensionManager.java +++ b/compiler/core/src/zserio/tools/ExtensionManager.java @@ -144,10 +144,23 @@ private File getWorkingDirectory() { try { - final URL execUrl = getClass().getProtectionDomain().getCodeSource().getLocation(); - System.out.println("execUrl = " + execUrl); - final String decodedExecUrlPath = URLDecoder.decode(execUrl.getPath(), "UTF-8"); - final File decodedExecFile = new File(new URI(decodedExecUrlPath)); + final String execUrlPath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); + final String decodedExecUrlPath = URLDecoder.decode(execUrlPath, "UTF-8"); + // check if decodedExecUrlPath is really URL, newer Java versions 11 or 17 returns normal path + System.out.println("decodedExecUrlPath = " + decodedExecUrlPath); + File decodedExecFile = null; + try + { + decodedExecFile = new File(new URI(decodedExecUrlPath)); + } + catch (URISyntaxException | IllegalArgumentException excpt) + { + decodedExecFile = new File(decodedExecUrlPath); + } + if (decodedExecFile.getPath().startsWith("file:")) + { + decodedExecFile = new File(decodedExecFile.getPath().replaceFirst("^file:", "")); + } System.out.println("decodedExecFile = " + decodedExecFile); System.out.println("decodedExecFile.getParentFile() = " + decodedExecFile.getParentFile()); @@ -156,7 +169,7 @@ private File getWorkingDirectory() return decodedExecFile.getParentFile(); } - catch (SecurityException | URISyntaxException | UnsupportedEncodingException excpt) + catch (SecurityException | UnsupportedEncodingException excpt) { return null; }