mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
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:
parent
b04304b691
commit
329010d29e
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user