diff --git a/CHANGELOG.md b/CHANGELOG.md index 94007f9468..f8a8e812e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.0.5 * enhancement - configure extra VM arguments in VS Code settings, used to launch the Java Language Server. See [#25](https://github.com/redhat-developer/vscode-java/issues/25). * enhancement - configure java.home property in VS Code settings. See [#28](https://github.com/redhat-developer/vscode-java/issues/28). +* enhancement - support running the Java Language Server with Java 9. See [#43](https://github.com/redhat-developer/vscode-java/issues/43). ## 0.0.4 (September 26, 2016) * enhancement - improved Javadoc/Markdown formatting. See [#13](https://github.com/redhat-developer/vscode-java/issues/13). diff --git a/src/extension.ts b/src/extension.ts index 4c9229dd37..491fb2fb2e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -44,7 +44,7 @@ function runJavaServer(){ params.push('-Dlog.protocol=true'); params.push('-Dlog.level=ALL'); } - + params.push('-jar'); params.push(path.resolve( __dirname ,'../../server/plugins/org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar')); //select configuration directory according to OS let configDir = 'config_win'; @@ -55,6 +55,9 @@ function runJavaServer(){ } params.push('-configuration'); params.push(path.resolve( __dirname ,'../../server',configDir)); params.push('-data'); params.push(workspacePath); + if (requirements.java_version > 8) { + params.push('--add-modules=java.se.ee'); + } let vmargs = workspace.getConfiguration("java").get("jdt.ls.vmargs",""); parseVMargs(params, vmargs); diff --git a/src/requirements.ts b/src/requirements.ts index 519a94a77c..40b1c0b81d 100644 --- a/src/requirements.ts +++ b/src/requirements.ts @@ -12,6 +12,7 @@ const findJavaHome = require('find-java-home'); interface RequirementsData { java_home: string + java_version: number } interface ErrorData { @@ -29,9 +30,9 @@ interface ErrorData { */ export async function resolveRequirements(): Promise { let java_home = await checkJavaRuntime(); - let isJava8 = await checkJavaVersion(java_home); + let javaVersion = await checkJavaVersion(java_home); let serverInstalled = await checkServerInstalled(); - return Promise.resolve({ "java_home": java_home }); + return Promise.resolve({ "java_home": java_home, "java_version":javaVersion}); } async function checkJavaRuntime(): Promise { @@ -78,10 +79,12 @@ async function checkJavaRuntime(): Promise { async function checkJavaVersion(java_home: string): Promise { return new Promise((resolve, reject) => { let result = cp.execFile(java_home + '/bin/java', ['-version'], {}, (error, stdout, stderr) => { - if (stderr.indexOf('1.8') < 0) - openJDKDownload(reject, "Java 8 is required to run. Please download and install a JDK 8."); - else - resolve(true); + if (stderr.indexOf('1.8') < 0 && stderr.indexOf('9.') < 0) { + openJDKDownload(reject, "Java 8 minimum is required to run. Please download and install the latest JDK."); + } else { + let version = (stderr.indexOf('1.8') >= 0)?8:9; + resolve(version); + } }); }); }