From 146674f290dc0456288f2ebc12218f34ab719416 Mon Sep 17 00:00:00 2001 From: mabruce Date: Tue, 24 Feb 2015 11:47:03 -0800 Subject: [PATCH] Feed javacpp.jar path to temp file deleter Get OS-localized file path to jar file enclosing Loader class, and feed this path to the temp file deleter on Windows instead of java.class.path. If the java program is launched through a dedicated classpath loader, java.class.path may not contain the javacpp jar. By locating the correct jar, this circumstance should be avoided. --- src/main/java/org/bytedeco/javacpp/Loader.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bytedeco/javacpp/Loader.java b/src/main/java/org/bytedeco/javacpp/Loader.java index 16cbafdba..ae2645bc3 100644 --- a/src/main/java/org/bytedeco/javacpp/Loader.java +++ b/src/main/java/org/bytedeco/javacpp/Loader.java @@ -26,6 +26,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; +import java.net.URISyntaxException; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; @@ -569,12 +570,14 @@ public static String loadLibrary(URL[] urls, String libnameversion) { LinkedList command = new LinkedList(); command.add(System.getProperty("java.home") + "/bin/java"); command.add("-classpath"); - command.add(System.getProperty("java.class.path")); + command.add((new File(Loader.class.getProtectionDomain().getCodeSource().getLocation().toURI())).toString()); command.add(Loader.class.getName()); command.add(tempDir.getAbsolutePath()); new ProcessBuilder(command).start(); } catch (IOException e) { throw new RuntimeException(e); + } catch (URISyntaxException e) { + throw new RuntimeException(e); } } });