Building Native Image
Developmentbuilding-native-imageBuilding Native Image is an Agent Skill for development published in the oracle/graal repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Build and troubleshoot GraalVM Native Image applications. Use this skill to build Java applications with GraalVM Native Image, configure CLI options, or resolve build or runtime issues.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/oracle/graal/blob/HEAD/docs/reference-manual/native-image/assets/skills/building-native-image/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/building-native-image, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
# Building Native Image
Prerequisites
- Set
JAVA_HOMEto a GraalVM distribution if your Java program uses the Native Image SDK. If you do not know the path, ask the user to provide it.
Build and Run
- Compile your Java file with
javac. - Build the Native Image:
$JAVA_HOME/bin/native-image <app-name> - Run the resulting executable:
./app-name - If Native Image cannot find your class file, set the classpath explicitly with the
-cpoption.
Troubleshooting
Reachability Metadata
If you encounter runtime errors related to reflection, JNI, resources, serialization, or dynamic proxies, consult references/reachability-metadata.md before attempting a fix. Use this reference for:
NoClassDefFoundErrororMissingReflectionRegistrationErrorMissingJNIRegistrationErrorMissingResourceException(missing resource bundle)- Any user question about reflection, JNI, proxies, resources, resource bundles, or serialization in Native Image.
Native Image Options
To configure classpath, optimization level, output name, platform target, monitoring, or other CLI flags, see references/native-image-options.md.
Reference Files
| Topic | File |
|---|---|
| Native Image CLI options | references/native-image-options.md |
| Missing reachability metadata | references/reachability-metadata.md |