vscode-antlr4
vscode-antlr4 copied to clipboard
Allow specifying a Java binary to run the ANTLR4 jar with
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. 👍
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.
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. :)
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.
🥇 THAT WOULD BE GREAT!
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?
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.
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 ?