Normalize paths in JvmUtils
Fixes problem in Windoze where file paths cannot be so easily converted to URLs. Fixes gh-767
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.loader.tools;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
@@ -42,7 +43,7 @@ abstract class JvmUtils {
|
||||
String javaHome = getJavaHome();
|
||||
for (String location : TOOLS_LOCATIONS) {
|
||||
try {
|
||||
URL url = new URL("file://" + javaHome + "/" + location);
|
||||
URL url = new URL(javaHome + "/" + location);
|
||||
if (new File(url.toURI()).exists()) {
|
||||
return url;
|
||||
}
|
||||
@@ -55,7 +56,13 @@ abstract class JvmUtils {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user