diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/LanguageServer.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/LanguageServer.java index 7037f56327..709f03d39d 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/LanguageServer.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/LanguageServer.java @@ -10,8 +10,12 @@ *******************************************************************************/ package org.eclipse.jdt.ls.core.internal; +import java.io.File; + +import org.eclipse.core.runtime.Platform; import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.osgi.service.datalocation.Location; public class LanguageServer implements IApplication { @@ -22,6 +26,15 @@ public class LanguageServer implements IApplication { @Override public Object start(IApplicationContext context) throws Exception { + Location instanceLoc = Platform.getInstanceLocation(); + if (!instanceLoc.lock()) { + File workspaceFile = new File(instanceLoc.getURL().getFile()); + if (workspaceFile.exists()) { + JavaLanguageServerPlugin.logError("Could not launch the server because associated workspace is currently in use by another Java LS server."); + } + return IApplication.EXIT_OK; + } + JavaLanguageServerPlugin.startLanguageServer(this); synchronized(waitLock){ while (!shutdown) {