jbang icon indicating copy to clipboard operation
jbang copied to clipboard

jbang --native calls the wrong native-image.exe executable on Windows 11 Pro

Open mhagnumdw opened this issue 3 weeks ago • 2 comments

Problem

On Windows 11 Pro, jbang --native MyApp.java fails with the following error:

[jbang] log: C:\Users\duck\AppData\Local\Temp\jbang16708381119093942353native-image
[jbang] [ERROR] Cannot run program ""C:\PROGRA~1\Java\graalvm-jdk-25.0.1+8.1\bin\native-image.exe"": CreateProcess error=2, The system cannot find the file specified
[jbang] Run with --verbose for more details. The --verbose must be placed before the jbang command. I.e. jbang --verbose run [...]

The correct path to the executable is "C:\Program Files\Java\graalvm-jdk-25.0.1.8.1\lib\svm\bin\native-image.exe" and not the one indicated in the error above.

As a simple workaround

mklink "C:\Program Files\Java\graalvm-jdk-25.0.1.8.1\bin\native-image.exe" "C:\Program Files\Java\graalvm-jdk-25.0.1.8.1\lib\svm\bin\native-image.exe"

Versions

C:\Users\duck\myapp>jbang --version
0.135.0

C:\Users\duck\myapp>java --version
java 25.0.1 2025-10-21 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 25.0.1+8.1 (build 25.0.1+8-LTS-jvmci-b01)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 25.0.1+8.1 (build 25.0.1+8-LTS-jvmci-b01, mixed mode, sharing)

C:\Users\duck\myapp>native-image.cmd --version
native-image 25.0.1 2025-10-21
GraalVM Runtime Environment Oracle GraalVM 25.0.1+8.1 (build 25.0.1+8-LTS-jvmci-b01)
Substrate VM Oracle GraalVM 25.0.1+8.1 (build 25.0.1+8-LTS, serial gc, compressed references)

Installation method:

  • GraalVM following the steps at https://www.graalvm.org/latest/getting-started/windows/
  • JBang: iex "& { $(iwr -useb https://ps.jbang.dev) } app setup" , ref: https://www.jbang.dev/documentation/jbang/latest/installation.html#universal-all-platforms

Perhaps related: https://github.com/jbangdev/jbang/issues/1394

mhagnumdw avatar Dec 02 '25 17:12 mhagnumdw

the guide you link to state its actually native-image.cmd that should be used. I would be very suprirsed if one have to now look for native-image command outside PATH that should have /bin in it.

Does your graalvm install not have a native-image.cmd either in bin?

maxandersen avatar Dec 04 '25 22:12 maxandersen

Does your graalvm install not have a native-image.cmd either in bin?

Yes, it does. Below is its content:

@echo off

call :getScriptLocation location
set "GRAALVM_ARGUMENT_VECTOR_PROGRAM_NAME=%~0"
"%location%..\lib\svm\bin\native-image.exe" %*
exit /b %errorlevel%

:: If this script is in `%PATH%` and called quoted without a full path (e.g., `"js"`), `%~dp0` is expanded to `cwd`
:: rather than the path to the script.
:: This does not happen if `%~dp0` is accessed in a subroutine.
:getScriptLocation variableName
    set "%~1=%~dp0"
    exit /b 0

I downloaded GraalVM from: https://download.oracle.com/graalvm/25/latest/graalvm-jdk-25_windows-x64_bin.zip

mhagnumdw avatar Dec 05 '25 00:12 mhagnumdw