Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.8.6
-
None
-
Patch
Description
If you try to find `javac` in a Linux JDK using `Toolchain.findTool()` method, this will fail when the build is running on Windows, since the implementation JavaToolchainImpl#findTool() appends ".exe" to the toolName (causing `javac.exe` is not found):
private static File findTool( String toolName, File installFolder ) { File bin = new File( installFolder, "bin" ); //NOI18N if ( bin.exists() ) { File tool = new File( bin, toolName + ( Os.isFamily( "windows" ) ? ".exe" : "" ) ); // NOI18N if ( tool.exists() ) { return tool; } } return null; }
The current workaround is to manually add a fake `javac.exe` file to the JDK `bin` directory. See tool chain issue (building linux image on windows machine) in moditect project.
The `findTool` method could yet easily be changed to search for exact `toolName` as requested, with a fallback to `toolName.exe` for backward compatibility:
private static File findTool( String toolName, File installFolder ) { File bin = new File( installFolder, "bin" ); if ( bin.exists() ) { File tool = new File( bin, toolName ); if ( tool.exists() ) { return tool; } File toolExe = new File( bin, toolName + ".exe" ); if ( toolExe.exists() ) { return toolExe; } } return null; }
This would solve the problem.
Attachments
Issue Links
- links to