Skip to content

Commit 4ce0549

Browse files
authored
fallback to search /usr/lib/jvm for jdks on Linux (#1706)
* fallback to search /usr/lib/jvm for jdks on Linux Signed-off-by: Yan Zhang <[email protected]> * update changelog Signed-off-by: Yan Zhang <[email protected]>
1 parent 0aa9b76 commit 4ce0549

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* bug fix - Quarkus: generated sources are not accessible. See [#1675](https://github.com/redhat-developer/vscode-java/issues/1675)
55
* bug fix - Error in every java file after updating to macOS Big Sur. See [#1700](https://github.com/redhat-developer/vscode-java/issues/1700).
66
* bug fix - Fix jdk detection: cover symlink folder on Linux. See [#1704](https://github.com/redhat-developer/vscode-java/pull/1704).
7+
* bug fix - Fix jdk detection: cover common JDK installation places on Linux. See [#1706](https://github.com/redhat-developer/vscode-java/pull/1706).
78
* other - Improve tracing capability of m2e through m2e.logback.configuration.. See [JLS#1589](https://github.com/eclipse/eclipse.jdt.ls/pull/1589).
89
* other - Infer expressions if there is no selection range when extracting method. See [#1680](https://github.com/redhat-developer/vscode-java/pull/1680).
910

src/findJavaRuntimes.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const expandHomeDir = require("expand-home-dir");
1010
const WinReg = require("winreg-utf8");
1111
const isWindows: boolean = process.platform.indexOf("win") === 0;
1212
const isMac: boolean = process.platform.indexOf("darwin") === 0;
13+
const isLinux: boolean = process.platform.indexOf("linux") === 0;
1314
const JAVAC_FILENAME = "javac" + (isWindows ? ".exe" : "");
1415
const JAVA_FILENAME = "java" + (isWindows ? ".exe" : "");
1516

@@ -236,6 +237,24 @@ async function fromCommonPlaces(): Promise<string[]> {
236237
}
237238
}
238239

240+
// common place for Linux
241+
if (isLinux) {
242+
const jvmStore = "/usr/lib/jvm";
243+
let jvms: string[] = [];
244+
try {
245+
jvms = await fse.readdir(jvmStore);
246+
} catch (error) {
247+
// ignore
248+
}
249+
for (const jvm of jvms) {
250+
const proposed = path.join(jvmStore, jvm);
251+
const javaHome = await verifyJavaHome(proposed, JAVAC_FILENAME);
252+
if (javaHome) {
253+
ret.push(javaHome);
254+
}
255+
}
256+
}
257+
239258
return ret;
240259
}
241260

0 commit comments

Comments
 (0)