I've explicitly set "java.home": "/usr/lib/jvm/java-8-openjdk-amd64" however the JAVA_HOME env variable is also set to exactly that (the result is the same regardless), eclipse has no issue with this, however the extension reports "The java.home variable defined in VS Code settings does not point to a JDK."
JDK 8 is not found
JDK 8 is found
I can confirm that setting java.home on the vscode settings is breaking the server.
Spoke too soon. I had a typo on the java.home setting. It seems to be working fine for me on ubuntu 16.04.
I have exactly the same issue on
@Coderah @AriHrannar please give 0.1.0 a try, and if the problem still persists, open the VS Code Developer Tools to see why the extension fails to start.
ping @Coderah @AriHrannar ^^
@fbricon its fixed for me in the newest version of the extension (0.1.0) :) thank you!
I created a super simple vscode extension and imported path-exists and added the following
let javaHome = process.env['JAVA_HOME'];
console.log(`JAVA_HOME: ${javaHome}`);
console.log('pathExists: ' + pathExists.sync(javaHome));
When activate the extension I get
JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-5.b14.fc27.x86_64
extension.js:19
pathExists: false
Even though the path exist
ls -dl /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-5.b14.fc27.x86_64
drwxr-xr-x. 7 root root 4096 1 mar 19.42 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-5.b14.fc27.x86_64
@attiand can you put a breakpoint in node_modules/path-exists/index.jsL15 and see why it fails?
@attiand can you try the following:
"java.home": "/usr/lib/jvm/java-1.8.0-openjdk/"
or
"java.home": "/usr/lib/jvm/java-1.8.0/"
@fbricon the exception is:
Error: ENOENT: no such file or directory, access '/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-5.b14.fc27.x86_64'
code: "ENOENT"
errno: -2
message: "ENOENT: no such file or directory, access '/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-5.b14.fc27.x86_64'"
path: "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-5.b14.fc27.x86_64"
@snjeza I added the following
let javaHome = process.env['JAVA_HOME'];
console.log(`JAVA_HOME: ${javaHome}`);
console.log('pathExists: ' + pathExists.sync(javaHome));
console.log('pathExists - 2: ' + pathExists.sync('/usr/lib/jvm/java-1.8.0-openjdk/'));
console.log('pathExists - 3: ' + pathExists.sync('/usr/lib/jvm/'));
console.log('pathExists - 4: ' + pathExists.sync('/home/mattias/'));
which prints (note the last line which I have drwx------ access to):
JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-5.b14.fc27.x86_64
pathExists: false
pathExists - 2: false
pathExists - 3: false
pathExists - 4: true
The following ordinary javascript:
'use strict';
var pathExists = require("path-exists");
var javaHome = process.env['JAVA_HOME'];
console.log("JAVA_HOME: " + javaHome);
console.log('pathExists: ' + pathExists.sync(javaHome));
console.log('pathExists - 2: ' + pathExists.sync('/usr/lib/jvm/java-1.8.0-openjdk/'));
console.log('pathExists - 3: ' + pathExists.sync('/usr/lib/jvm/'));
console.log('pathExists - 4: ' + pathExists.sync('/home/mattias/'));
prints:
;node test.js
JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.fc27.x86_64
pathExists: true
pathExists - 2: true
pathExists - 3: true
pathExists - 4: true
@attiand could you try to make your small vscode extension use const fs = require('fs'); and then check fs.accessSync(javaHome);? If that fails then it's probably a bug in vscode/electron and we need to report it upstream.
@fbricon, that throws Error: ENOENT: no such file or directory, access '/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-5.b14.fc27.x86_64'
Here is the extension: https://gist.github.com/attiand/16e24564dac93f5fa93bc3035e28596d
@akurtakov does it look like your issue?
Yes, looks exactly the same.
I've also got the problem.
Operating System: Ubuntu 18.04 LTS
JDK version: OpenJDK 11
Visual Studio Code version: 1.26.1
Java extension version: 0.29.0
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
The JAVA_HOME environment variable does not point to a JDK.
I removed Oracle JDK 8 and update-alternatives uses /usr/lib/jvm/java-11-openjdk-amd64, then it works.
:confused:
Edit the User Settings
~/.config/Code/User/settings.json
{
"git.ignoreLegacyWarning": true,
"workbench.colorTheme": "GitHub Plus",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"java.home": "/usr/lib/jvm/java-8-openjdk-amd64/"
}
then restart vscode.
Most helpful comment
@attiand can you try the following:
or