Commit 329010d2 authored by Dave Syer's avatar Dave Syer

Normalize paths in JvmUtils

Fixes problem in Windoze where file paths cannot be so easily
converted to URLs.

Fixes gh-767
parent b04304b6
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.loader.tools; package org.springframework.boot.loader.tools;
import java.io.File; import java.io.File;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
...@@ -42,7 +43,7 @@ abstract class JvmUtils { ...@@ -42,7 +43,7 @@ abstract class JvmUtils {
String javaHome = getJavaHome(); String javaHome = getJavaHome();
for (String location : TOOLS_LOCATIONS) { for (String location : TOOLS_LOCATIONS) {
try { try {
URL url = new URL("file://" + javaHome + "/" + location); URL url = new URL(javaHome + "/" + location);
if (new File(url.toURI()).exists()) { if (new File(url.toURI()).exists()) {
return url; return url;
} }
...@@ -55,7 +56,13 @@ abstract class JvmUtils { ...@@ -55,7 +56,13 @@ abstract class JvmUtils {
} }
private static String getJavaHome() { private static String getJavaHome() {
return System.getProperty("java.home"); try {
return new File(System.getProperty("java.home")).toURI().toURL()
.toExternalForm();
}
catch (MalformedURLException e) {
throw new IllegalStateException("Cannot locate java.home", e);
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment