2

My application that is built with gradle is not able to be packaged with graal's native image command.

I build the combined jar using:

gradlew --no-daemon assemble

Then, I test my cli application using:

java -jar build/libs/stackoverflow-cli-0.1-all.jar search -q "merge maps" -t java

The output is what I expected, so that's good. However, I then want to create the native binary using graalvm. So I run this command:

native-image --no-server -cp build/libs/stackoverflow-cli-0.1-all.jar

It immediately fails with the following error:

Warning: Ignoring server-mode native-image argument --no-server.
Error: Please specify class containing the main entry point method. (see --help)

I thought this was weird. The next thing I tried was to specify the main class as the error suggested:

native-image --no-server -cp build/libs/stackoverflow-cli-0.1-all.jar com.eddie.StackoverflowCliCommand

That gives me a different error:

Warning: Ignoring server-mode native-image argument --no-server.
[com.ivansinsurance.stackoverflowclicommand:1544]    classlist:   3,060.25 ms,  0.96 GB
[com.ivansinsurance.stackoverflowclicommand:1544]        setup:     809.46 ms,  0.96 GB
Error: Default native-compiler executable 'cl.exe' not found via environment variable PATH
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1

I don't know what this error means. Here is the version of java I'm using:

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)

Any help is greatly appreciated!

Eddie Greathouse
  • 125
  • 1
  • 5
  • 14
  • That answer seemed specific to Microsoft Visual Studio, which I'm not using. – Eddie Greathouse Apr 20 '21 at 18:12
  • 1
    After searching, I found (despite not using GraallVM,....): [Prerequisites for Using Native Image on Windows](https://www.graalvm.org/reference-manual/native-image/#prerequisites-for-using-native-image-on-windows): *"Building native images on Windows requires a Microsoft Visual C++ (MSVC) that comes with Visual Studio 2017 15.5.5 or later."* - actually same as explained in the question I posted the link to... –  Apr 20 '21 at 18:26
  • I think you right. Trying it now... – Eddie Greathouse Apr 20 '21 at 18:42
  • Yup! That worked! I installed Visual Studio 2019. Then I launched x64 Native Tools Command Prompt for VS 2019 and ran 'native-image --no-server -cp build/libs/stackoverflow-cli-0.1-all.jar com.eddie.StackoverflowCliCommand' and that worked! – Eddie Greathouse Apr 20 '21 at 20:18

1 Answers1

3
  1. I installed Visual Studio 2019.

  2. Then I launched x64 Native Tools Command Prompt for VS 2019

  3. Then I ran:

    'native-image --no-server -cp build/libs/stackoverflow-cli-0.1-all.jar com.eddie.StackoverflowCliCommand'

and that worked!

Eddie Greathouse
  • 125
  • 1
  • 5
  • 14