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

Allow specifying a Java binary to run the ANTLR4 jar with #57

Closed
xied75 opened this issue Oct 31, 2018 · 8 comments
Closed

Allow specifying a Java binary to run the ANTLR4 jar with #57

xied75 opened this issue Oct 31, 2018 · 8 comments
Labels
feature request A request for a new feature

Comments

@xied75
Copy link

xied75 commented Oct 31, 2018

On my Windows 10 I have WSL enabled running Ubuntu 14.04, I got JDK8 installed there, now my VS Code is on Windows 10 directly, with your great antlr tooling, any chance I could tell it to use JDK in the WSL? That would save me to install JDK on my Windows directly. Strange question I know. 👍

@mike-lischke
Copy link
Owner

The extension uses whatever is available via PATH. Java is called without any path and relies on a search path set. So you are free to specify any path that can be accessed.

@xied75
Copy link
Author

xied75 commented Oct 31, 2018

As always thanks for the quick reply. Java binary under WSL is Linux binary, if we try to run it in cmd, it won't work. In order to run it within cmd, we need to call wsl java. As described here:
https://docs.microsoft.com/en-us/windows/wsl/interop

Thus I created a batch file named java.bat, put somewhere my PATH can reach, with contents like this:

@echo off
wsl java %*

now there is a problem, a windows path e.g. "c:\users\dong\Documents" would need to be converted into "/mnt/c/users/dong/Documents". So there should be more magic to add to above batch file. BTW, your code is not trying to locate a "java.exe" right?

So far seems not working yet, the antlr equalizer keeps going, apparently it still can't find java.

By all means if you feel this is not worth trying, feel free to ignore me. :)

@mike-lischke
Copy link
Owner

As the environment under which the extension runs can be quite different depending on the platform etc. no attempt is made to locate a Java installation. Instead the extension relies on the way how the OS finds a specific binary. However, it should be possible instead of hardcoding the java executable name to use anything else provided by the user (like a batch file) and pass all arguments to that (and the user provided file must take care to pass on any given argument).

Such a feature would also allow to run arbitrary Java executables, without having them on the search path. If you like that idea we can convert this question to a feature request.

@xied75
Copy link
Author

xied75 commented Nov 1, 2018

🥇
THAT WOULD BE GREAT!

@mike-lischke mike-lischke added feature request A request for a new feature and removed question labels Nov 1, 2018
@mike-lischke mike-lischke changed the title On Windows 10, use the JDK/JRE inside WSL? Allow specifying a Java binary to run the ANTLR4 jar with Nov 1, 2018
@ZengLawrence
Copy link

I have similar problem with setting Java JDK path since I am working on Javascript/Typescript projects and don't want to set Java in my path. It would be better to configure Java JDK path in extension settings.

When can this feature request be picked up?

@Hoernchen
Copy link

I'm also hitting this problem here, unfortunately vscode only allows adding env vars to the built in terminal, but not on a per project/global scope, so I'm left with a useless extension due to having no globally availlable java on windows that is in the path.

@lalishansh
Copy link

Question/Suggestion: Antlr4-tools are now available to install via pip installing Java Runtime Environment at $env:HOME/.jre/, so wouldn't be beneficial to provide java path, or better an option to edit/override antlr (and grun) invoke commands ?

parkerlamb added a commit to parkerlamb/vscode-antlr4 that referenced this issue May 27, 2024
…ws users to explicitly set JAVA_HOME if it is not present or if they wish to use a different Java installation. The Java executable is looked up at `${javaHomeOverride}/bin/java` in this case.

This also changes the default behavior to use `$JAVA_HOME/bin/java` as the Java executable.

If neither of `javaHomeOverride` or the JAVA_HOME environment variable are set then the extension attempts to launch `java` in PATH as before.

Fixes issue mike-lischke#57.
parkerlamb added a commit to parkerlamb/vscode-antlr4 that referenced this issue May 28, 2024
…ws users to explicitly set JAVA_HOME if it is not present or if they wish to use a different Java installation. The Java executable is looked up at `${javaHomeOverride}/bin/java` in this case.

This also changes the default behavior to use `$JAVA_HOME/bin/java` as the Java executable.

If neither of `javaHomeOverride` or the JAVA_HOME environment variable are set then the extension attempts to launch `java` in PATH as before.

Fixes issue mike-lischke#57.

Signed-off-by: Parker Lamb <parkerlamb@users.noreply.github.com>
parkerlamb added a commit to parkerlamb/vscode-antlr4 that referenced this issue May 28, 2024
…ws users to explicitly set JAVA_HOME if it is not present or if they wish to use a different Java installation. The Java executable is looked up at `${javaHomeOverride}/bin/java` in this case.

This also changes the default behavior to use `$JAVA_HOME/bin/java` as the Java executable.

If neither of `javaHomeOverride` or the JAVA_HOME environment variable are set then the extension attempts to launch `java` in PATH as before.

Fixes issue mike-lischke#57.

Signed-off-by: Parker Lamb <parkerlamb@users.noreply.github.com>
mike-lischke pushed a commit that referenced this issue May 29, 2024
…ws users to explicitly set JAVA_HOME if it is not present or if they wish to use a different Java installation. The Java executable is looked up at `${javaHomeOverride}/bin/java` in this case.

This also changes the default behavior to use `$JAVA_HOME/bin/java` as the Java executable.

If neither of `javaHomeOverride` or the JAVA_HOME environment variable are set then the extension attempts to launch `java` in PATH as before.

Fixes issue #57.

Signed-off-by: Parker Lamb <parkerlamb@users.noreply.github.com>
@mike-lischke
Copy link
Owner

Fixed by PR #273

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A request for a new feature
Projects
None yet
Development

No branches or pull requests

5 participants