'Does copying the main file output by native-image is the correct way to make native image in GraalVM?
My goal is to create native-image. I intend to create a native image of a "class Main that has 1 dependency of a class on different file". The idea is:
Main.javaimport classHelloWorld.
What nd did:
- I run this
java Main.java // output: Main.class and HelloWorld.class
native-image Main // output: main and main.build_artifacts.txt
cp main /app // copy main to /app folder
./main
It works, but I am not sure whether this is correct. I use Docker for this.
Dockerfile
FROM ghcr.io/graalvm/native-image:java11-21.2
WORKDIR /app
COPY ./src/main/java/ /app
RUN javac Main.java
RUN native-image Main
FROM ghcr.io/graalvm/jdk:java11-21.2
WORKDIR /app
COPY --from=0 /app/main /app/main
CMD ./main
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
