diff --git a/src/main/java/org/scijava/launcher/Java.java b/src/main/java/org/scijava/launcher/Java.java index 8705679..dc9b299 100644 --- a/src/main/java/org/scijava/launcher/Java.java +++ b/src/main/java/org/scijava/launcher/Java.java @@ -325,6 +325,19 @@ public static void upgrade(BiConsumer subscriber) String configFileValue = System.getProperty("scijava.app.config-file"); if (configFileValue != null && !configFileValue.isEmpty()) { File configFile = new File(configFileValue); + String appDirValue = System.getProperty("scijava.app.directory"); + if (appDirValue != null) { + Path appDirPath = Paths.get(appDirValue).normalize().toAbsolutePath(); + // If possible, use a path relative to the application directory. + // This improves portability if the application gets moved + // elsewhere, and/or accessed from multiple operating systems. + try { + newJavaPath = appDirPath.relativize(newJavaPath); + } + catch (IllegalArgumentException exc) { + Log.debug(exc); + } + } Config.update(configFile, "jvm.dir", newJavaPath.toString()); } }