-
Notifications
You must be signed in to change notification settings - Fork 10
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
error ANT02: Cannot find Java executable, currently set to '/usr/bin/java' #30
Comments
Thanks for the info. I've been trying to make Antlr4BuildTasks not have any dependencies, and include both the most recent Antlr tool jar (now 4.10) and a JRE for Windows. This idea is ok for the Antlr tool jar because I can download the file from Maven Central another version, and I think a probe path for something else. For the JRE, I've included a version for Windows, and assume a hardwired location for non-Windows. This probably isn't going to work because I really don't want to create JRE's for every architecture and add it to the Nuget package--it's just too much junk in one file. I will need to fish around to find out who's has a server full of JRE's so I can just fetch the right one if I can't find one on the current path. And, even that may not work depending on which version of the Antlr jar one is using. Point taken. I will add something back in to indicate where to find Java because I'll not likely be able to pick out the right JRE. But it'll likely not be called "AntlrvsixJavaExec" because it has nothing to do with the old Antlr Visual Studio Extension, and instead call it JavaExec. |
Thanks for the update! Just another note is that our docker container is using the Microsoft image which I believe is alpine linux (I could be wrong) and not windows. We are using https://hub.docker.com/_/microsoft-openjdk-jdk to get a jdk into our docker image and I have tried pointing this to /usr/bin/java with not a lot of success |
Just a bit of an update, I was able to point the JDK to /usr/bin/java using this: My problem now is that I have a different error message:
I am wondering if my docker container is maybe missing some required files for this? |
If you hang on, I will update the code and release soon. There's been kind of a mess going on with the Antlr grammars-vr repo with the new 4.10 Antlr release, but I'll get this done now. |
Hi Martin, I have a solution that might work for you. Basically it involves a mod to your .csproj file for
So, here the location of the Java executable is the full path file name. The reason it's in the .csproj because I expect the Antlr tool .jar file to be Java version dependent at some point. They're likely going to upgrade the version of Java used to build the tool. This solution of having it in the .csproj file isn't exactly "OS independent" .csproj though. But, it is in the UI when you use the Visual Studio IDE and look at the properties of the .g4 in the project explorer. You might be able to pass the parameter with an environmental variable. Anyways, I just released a version with this, 10.1 Antlr4BuildTasks. |
To make things more interesting. Would it be possible to add a check (or a setting) that detects that installed OS java version is compatible (not too old) and use the bundled one in such case ? |
I agree. I'll have to go through and see what the min Java versions are required per Antlr4 tool and runtime versions (note, they can be different). Then, I'll have to check the version by running java. I'm probably going to add code to download a JRE from OpenJDK if the java version on path or specified in the .csproj isn't workable. |
@kaby76 - Ken, is the assurance in the README that the tool will download a JRE into .jre now out of date? This just bit me - if it is, I'll submit a PR with some revised wording if you don't want to fix it yourself. If not, something weird just happened to me and the .m2 downloaded and the .jre didn't! Lovely, lovely tool - thank you for this! |
It should be downloading the JRE, but won't if
I don't think I say that in quite so many words though. It is a nice tool, but kudos really should go to Harwell who somehow figured out how to do this via a package reference to nuget. Really a remarkable insight. I just been hacking at it to clean up some of the rough edges. |
Sorry to piggy back off of this question but I seem to be having the same issue all of the sudden. (Just migrated to a new PC)
This is my project file:
Any thoughts on why this is not longer building? |
Actually - I had the wrong format earlier. This fixed it. Is that how it should be declared going forwards ?
|
I'll publish the next release today. It should have the fix. If not let me know. Ken |
Yes that should be fine....JavaExec. Alternatively I think it looks for a java executable on PATH. It does check to make sure the executable is at least version 11 or more recent. Otherwise the Antlrr java .jar tool cannot work. |
This is happening trying to update to version 10 and running this package in a docker container with a .net solution.
Typical build instruction would be :
RUN dotnet build *****.csproj -c "*****" -o /app/build -p:AntlrvsixJavaExec="${JAVA_HOME}/bin/java"
AntlrvsixJavaExec is a path we are using that points to the java executable and this works with previous changes. Has this property changed at all do you know?
The text was updated successfully, but these errors were encountered: