Skip to content

JAVA_HOME check is not OS independent #849

Closed
@fipro78

Description

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.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions