Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find JDK 8, it exists, eclipse has no issue, path is correct #157

Closed
Coderah opened this issue Feb 24, 2017 · 18 comments
Closed

Comments

@Coderah
Copy link

Coderah commented Feb 24, 2017

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

@gorkem gorkem added the bug label Feb 27, 2017
@gorkem
Copy link
Contributor

gorkem commented Feb 27, 2017

I can confirm that setting java.home on the vscode settings is breaking the server.

@gorkem
Copy link
Contributor

gorkem commented Feb 27, 2017

Spoke too soon. I had a typo on the java.home setting. It seems to be working fine for me on ubuntu 16.04.

@AriHrannar
Copy link

I have exactly the same issue on

  • OS: Ubuntu 16.04
  • JDK version: OpenJDK 8
  • VSC version: 1.10.1
  • Java extension version: 0.0.11

@fbricon
Copy link
Collaborator

fbricon commented Mar 31, 2017

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

@fbricon
Copy link
Collaborator

fbricon commented Apr 18, 2017

ping @Coderah @AriHrannar ^^

@AriHrannar
Copy link

@fbricon its fixed for me in the newest version of the extension (0.1.0) :) thank you!

@attiand
Copy link

attiand commented Mar 22, 2018

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
  • Fedora release 27
  • VS Code 1.21.1

@fbricon
Copy link
Collaborator

fbricon commented Mar 22, 2018

@attiand can you put a breakpoint in node_modules/path-exists/index.jsL15 and see why it fails?

@snjeza
Copy link
Contributor

snjeza commented Mar 22, 2018

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

@attiand
Copy link

attiand commented Mar 23, 2018

@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

@fbricon
Copy link
Collaborator

fbricon commented Apr 6, 2018

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

@attiand
Copy link

attiand commented Apr 7, 2018

@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

@fbricon
Copy link
Collaborator

fbricon commented Jul 16, 2018

@akurtakov does it look like your issue?

@akurtakov
Copy link

Yes, looks exactly the same.

@SiqingYu
Copy link

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.

@SiqingYu
Copy link

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

@liuxk99
Copy link

liuxk99 commented Jul 22, 2019

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.

@rgrunber
Copy link
Member

Closing this issue for now as there have been a lot of updates/improvements to JDK detection. For example we've moved away from find-java-home to jdk-utils ( #2246 ). If this issue persists today, feel free to re-open and we can have a closer look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants