diff --git a/eclipse-language-servers/org.springframework.tooling.boot.java.ls/src/org/springframework/tooling/boot/java/ls/SpringBootJavaLanguageServer.java b/eclipse-language-servers/org.springframework.tooling.boot.java.ls/src/org/springframework/tooling/boot/java/ls/SpringBootJavaLanguageServer.java index 5169ff4a5..64a87debd 100644 --- a/eclipse-language-servers/org.springframework.tooling.boot.java.ls/src/org/springframework/tooling/boot/java/ls/SpringBootJavaLanguageServer.java +++ b/eclipse-language-servers/org.springframework.tooling.boot.java.ls/src/org/springframework/tooling/boot/java/ls/SpringBootJavaLanguageServer.java @@ -39,13 +39,7 @@ public class SpringBootJavaLanguageServer extends STS4LanguageServerProcessStrea commands.add("-Dlsp.completions.indentation.enable=true"); commands.add("-Xmx1024m"); commands.add("-cp"); - File toolsJar = getToolsJAR(); - if (toolsJar!=null) { - commands.add(toolsJar + File.pathSeparator + getLanguageServerJARLocation()); - } else { - //TODO: issue a 'missing tools.jar warning somehow depending on the platform? - commands.add(getLanguageServerJARLocation()); - } + commands.add(getToolsJAR() + File.pathSeparator + getLanguageServerJARLocation()); commands.add("org.springframework.boot.loader.JarLauncher"); String workingDir = getWorkingDirLocation(); diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageServerProcessStreamConnector.java b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageServerProcessStreamConnector.java index c362e0b21..e5e89c430 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageServerProcessStreamConnector.java +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageServerProcessStreamConnector.java @@ -12,11 +12,8 @@ package org.springframework.tooling.ls.eclipse.commons; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.function.Consumer; +import org.eclipse.core.runtime.Path; import org.eclipse.jdt.internal.launching.StandardVMType; import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider; @@ -53,58 +50,11 @@ public class STS4LanguageServerProcessStreamConnector extends ProcessStreamConne return null; } - /** - * Different places to look for tools jar, relative to Java home. - */ - private static String [] TOOLS_JAR_PATHS = { - "../lib/tools.jar", - "lib/tools.jar" - }; - - protected File getToolsJAR() { - List jhomes = new ArrayList<>(2); - resolve(System.getenv("JAVA_HOME"), jhomes::add); - resolve(System.getProperty("java.home"), jhomes::add); - for (File jhome : jhomes) { - for (String tjPath : TOOLS_JAR_PATHS) { - File toolsJar = new File(jhome, tjPath); - if (toolsJar.isFile()) { - return toolsJar; - } - } - } - return null; + protected String getToolsJAR() { + File jre = new File(System.getProperty("java.home")); + return new File(jre.getParent(), "lib" + Path.SEPARATOR + "tools.jar").getAbsolutePath(); } - private void resolve(String path, Consumer requestor) { - if (path!=null) { - try { - File file = new File(path).getCanonicalFile(); - if (file.exists()) { - requestor.accept(file); - return; - } - } catch (IOException e) { - //Ignore... this can happen because it tries to handle symbolic links - } - } - } - - private File getJavaHomeFromEnv() { - try { - File jhome = new File(System.getenv("JAVA_HOME")); - if (jhome!=null) { - jhome = jhome.getCanonicalFile(); - if (jhome.isDirectory()) { - return jhome; - } - } - } catch (IOException e) { - //Ignore... this can happen because it tries to handle symbolic links - } - return null; - } - protected String getWorkingDirLocation() { return System.getProperty("user.dir"); }