Skip to content

Commit

Permalink
Fix eclipse-jdtls#43 support starting the JLS with Java 9
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <fbricon@gmail.com>
  • Loading branch information
fbricon committed Oct 11, 2016
1 parent 51aae6d commit 58d2a3e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
5 changes: 4 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand Down
15 changes: 9 additions & 6 deletions src/requirements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const findJavaHome = require('find-java-home');

interface RequirementsData {
java_home: string
java_version: number
}

interface ErrorData {
Expand All @@ -29,9 +30,9 @@ interface ErrorData {
*/
export async function resolveRequirements(): Promise<RequirementsData> {
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<any> {
Expand Down Expand Up @@ -78,10 +79,12 @@ async function checkJavaRuntime(): Promise<any> {
async function checkJavaVersion(java_home: string): Promise<any> {
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);
}
});
});
}
Expand Down

0 comments on commit 58d2a3e

Please sign in to comment.