build-native-image-maven
What it does
This skill helps Java developers turn their Maven projects into native programs that start quickly. It is for teams who want lighter, faster Java applications.
When to use it
- ✓When you want to build a Java application as a GraalVM native image with Maven.
- ✓When you need to add the native-maven-plugin to a pom.xml file.
- ✓When a native image build fails and you need help collecting metadata or fixing runtime problems.
Skill link
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/skills/build-native-image-maven/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Add a native profile to my Maven pom.xml so I can build my Java app as a native image.”
5 new skills a week. 1 minute to read.
How it works
It adds a native profile with the native-maven-plugin to the pom.xml, then builds with the Maven wrapper. It sets JAVA_HOME to a GraalVM JDK so the plugin can find the native-image tool.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Maven Native Image Build
Prerequisites
- Set
JAVA_HOMEto a GraalVM JDK installation so the plugin can findnative-image. - Do not require
GRAALVM_HOMEin the normal case. Only mention it if the user already relies on it or their environment needs an explicit override. - Use Maven 3.6+.
Plugin Setup
Add the following to your pom.xml inside a native profile:
<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.11.1</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
<execution>
<id>test-native</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<mainClass>org.example.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Build and Run
./mvnw -Pnative package # Build native image → target/<imageName>
./target/myapp # Run the native executable
./mvnw -Pnative test # Build and run JUnit tests as a native image
./mvnw -Pnative -DskipTests package # Skip all tests
./mvnw -Pnative -DskipNativeTests package # Run JVM tests only, skip native
Plugin Not Resolving or Activating
- "Could not resolve artifact" — Ensure
mavenCentral()is in repositories and the version is correct. - "Could not find goal 'compile-no-fork'" — Verify
<extensions>true</extensions>is set on the plugin. - Build runs without native compilation — Check you are activating the profile:
./mvnw -Pnative package.
Build or Runtime Failures
For class initialization errors, linking issues, memory problems, or unexpected runtime behavior, see references/maven-plugin-options.md.
Missing Reachability Metadata
When native-image reports missing reflection, resources, serialization, or JNI entries, see references/reachability-metadata.md.
Native Testing
For nativeTest failures or setting up native JUnit tests, see references/testing.md.
Reference Files
| Topic | File |
|---|---|
| Plugin configuration options | references/maven-plugin-options.md |
| Missing reachability metadata | references/reachability-metadata.md |
| Native testing | references/testing.md |
FAQ
What Maven version is needed?
Maven 3.6 or later.
Does it use GRAALVM_HOME?
Usually not. It relies on JAVA_HOME, and mentions GRAALVM_HOME only if you already use it.
Can it run native tests?
Yes. It sets up a test-native execution for native JUnit tests.
Details
Original description by the author
Build GraalVM native images using the native-maven-plugin (org.graalvm.buildtools). Use this skill to build Java applications with Maven, configure pom.xml native image settings, run native tests, collect metadata, or resolve build or runtime issues.
repo: oracle/graal
Popularity
- GitHub stars
- 22k
- Ranking position
- #10357
- License
- —
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
build-native-image-gradle
22kHelps your agent build Java apps into fast GraalVM native images with Gradle, and fix common build or runtime problems.
building-native-image
22kTeaches your agent to turn Java programs into fast standalone apps with GraalVM Native Image, and to fix common build or runtime errors.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.