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

JAVA_HOME check is not OS independent #849

Closed
fipro78 opened this issue Apr 6, 2022 · 1 comment
Closed

JAVA_HOME check is not OS independent #849

fipro78 opened this issue Apr 6, 2022 · 1 comment
Labels
Milestone

Comments

@fipro78
Copy link
Contributor

fipro78 commented Apr 6, 2022

I am running a Tycho build using 2.7.0 on Windows. Even with a JAVA_HOME environment variable set, the tycho log shows this.

"Could not find the Toolchain nor JAVA_HOME, trying java from PATH instead"

Looking into the AbstractTestMojo I can see this on line 1237:

File file = new File(javaHome, "bin/java");

Afterwards it is checked if the file exists, otherwise the message will be shown and Java will be resolved from the PATH.

On Windows the filename is java.exe

A possible solution would be to do an OS check to determine the filename:

String osName = System.getProperty("os.name");
String executable = osName.startsWith("Windows") ? "bin/java.exe" : "bin/java";
File file = new File(javaHome, executable);

Not sure if there is a more elegant or efficient way.

@laeubi
Copy link
Member

laeubi commented Apr 6, 2022

@fipro78 may thanks for the report I think one solution could be to simply check for both (java + java.exe), I also think the message could be improved (as JAVA_HOME is there but just the executable was not found on the path).

@laeubi laeubi added this to the 2.7.1 milestone Apr 6, 2022
laeubi added a commit to laeubi/tycho that referenced this issue Apr 6, 2022
@laeubi laeubi closed this as completed in 48bf1f8 Apr 6, 2022
laeubi added a commit that referenced this issue Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants