vscode-java: Unable to find JDK 8, it exists, eclipse has no issue, path is correct

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.”

Environment
  • Operating System: Ubuntu 15.04
  • JDK version: OpenJDK 8
  • Visual Studio Code version: 1.9.1
  • Java extension version: 0.0.10
Current Result

JDK 8 is not found

Expected Result

JDK 8 is found

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

@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/"

I removed Oracle JDK 8 and update-alternatives uses /usr/lib/jvm/java-11-openjdk-amd64, then it works. 😕

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.

@akurtakov does it look like your issue?

@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

@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.