diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JvmUtils.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JvmUtils.java index e96a01baf8..a5d1c7bfbd 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JvmUtils.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JvmUtils.java @@ -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); + } } }