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

Provide a way to disable embedded JRE #2276

Closed
cydparser opened this issue Jan 8, 2022 · 6 comments · Fixed by #2284
Closed

Provide a way to disable embedded JRE #2276

cydparser opened this issue Jan 8, 2022 · 6 comments · Fixed by #2284

Comments

@cydparser
Copy link

The embedded JRE assumes a traditional FHS directory structure on Linux. Nontraditional distributions, like NixOS, do not have directories like /lib and so the embedded Java executable cannot be used. The following opaque error occurs when opening a Java file on NixOS:

no such file or directory: /home/user/.vscode/extensions/redhat.java-1.2.0/jre/17.0.1-linux-x86_64/bin/java

The file exists, but it requests a nonexistent interpreter, /lib64/ld-linux-x86-64.so.2. Deleting the jre directory allows me to use the extension, but that is an unpleasant user experience. A setting to ignore the embedded JRE would be appreciated.

@Eskibear
Copy link
Contributor

Eskibear commented Jan 10, 2022

@cydparser
One way I can think of is to manually install the vsix package without embedded JDK. See https://github.com/redhat-developer/vscode-java/releases/tag/v1.2.0
And another way is to specify java.home (not recommended because it's deprecated) in vscode settings.json file, which points to the JDK to launch Java language server.

@testforstephen FYI, looks that the embedded JDK is not working on some unpopular Linux distros.

@testforstephen
Copy link
Collaborator

As far as I know (microsoft/vsmarketplace#288 (comment)), NixOS is not installing extensions via VS Code marketplace, but explicitly download Java extension from the specified URL. If so, can NixOS download the generic version without embedded JRE from the URL https://github.com/redhat-developer/vscode-java/releases/download/v1.2.0/redhat.java-1.2.0.vsix?

Besides, if NixOS doesn't follow FHS directory structure, how would you install JDK on NixOS?

@cydparser
Copy link
Author

@Eskibear
This comment indicates that java.home is not used by the version installed from the marketplace.

@cydparser
Copy link
Author

@testforstephen
There are multiple ways to install VS Code and extensions on NixOS with different tradeoffs. I installed VS Code through NixOS, but the extensions through the marketplace. A downside to managing the extensions with NixOS is that the versions often lag far behind.

NixOS installs everything in /nix/store/ and creates symlinks in either /run/current-system/sw/ for system installs or ~/.nix-profile/ for user installs.

@testforstephen
Copy link
Collaborator

testforstephen commented Jan 12, 2022

Another idea I had was that we could detect if the underlying Linux distribution follows the traditional FHS and automatically disable the embedded JRE if it is running on a non-FHS distribution.

Update: We can try to run the command "java -version" using the embedded JRE executable, and if it fails, disable embedded JRE.

@testforstephen
Copy link
Collaborator

Next version 1.3.0 will have a new setting "java.jdt.ls.java.home" that allows you to use a different JDK to start Java extension.

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