diff --git a/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java b/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java index 6a3b0ef9e04..34bef66a51c 100644 --- a/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java +++ b/contribs/application/src/main/java/org/matsim/application/MATSimApplication.java @@ -341,7 +341,8 @@ public static void run(Class clazz, String... args) // Pass stored args to the instance as well if (System.getenv().containsKey("MATSIM_GUI_ARGS")) { String[] guiArgs = System.getenv("MATSIM_GUI_ARGS").split(ARGS_DELIMITER); - args = ApplicationUtils.mergeArgs(args, guiArgs); + if (guiArgs.length > 0) + args = ApplicationUtils.mergeArgs(args, guiArgs); } } @@ -376,9 +377,12 @@ public static void runWithDefaults(Class clazz, Str if (ApplicationUtils.isRunFromDesktop()) { - String value = String.join(ARGS_DELIMITER, defaultArgs); - System.getenv().put("MATSIM_GUI_ARGS", value); + if (defaultArgs.length > 0) { + String value = String.join(ARGS_DELIMITER, defaultArgs); + System.setProperty("MATSIM_GUI_ARGS", value); + } + // args should be empty when run from desktop and is not used run(clazz, "gui"); } else { diff --git a/matsim/src/main/java/org/matsim/run/gui/ExeRunner.java b/matsim/src/main/java/org/matsim/run/gui/ExeRunner.java index 7c1b75eac56..fac8a5df38d 100644 --- a/matsim/src/main/java/org/matsim/run/gui/ExeRunner.java +++ b/matsim/src/main/java/org/matsim/run/gui/ExeRunner.java @@ -100,8 +100,8 @@ public void run() { // Copy the MATSIM_GUI_ARGS environment variable to the process environment // these arguments may be used internally by the matsim scenario - if (System.getenv().containsKey("MATSIM_GUI_ARGS")) { - processBuilder.environment().put("MATSIM_GUI_ARGS", System.getenv("MATSIM_GUI_ARGS")); + if (System.getProperty("MATSIM_GUI_ARGS") != null) { + processBuilder.environment().put("MATSIM_GUI_ARGS", System.getProperty("MATSIM_GUI_ARGS")); } if (workingDirectory != null) {