Important
Archived by Elide. Elide's fork of this project was retired on November 8, 2026 and is no longer maintained here. Its code, branches, and history remain available for reference. Upstream project: https://github.com/smasher164/staticjni.
Explore our current projects: myna, bemo, trufflecel, truffledata, and elide.
-
The header file
HelloWorld.hwas generated by runningjavac -h . HelloWorld.java. Since this is checked into the repo, it doesn't need to be run again.The dependency
org.graalvm.nativeimage/svmhas been added to the project. In this repo's case, the jar was unzipped into the classpath. If you're using a package manager or build system, follow their respective instructions to add a dependency. -
javac -cp . HelloWorld.java NativeFeature.java -
jar cfm HelloWorld.jar manifest.txt HelloWorld.class NativeFeature.class -
- Linux:
cc -c -I "$JAVA_HOME/include" -I "$JAVA_HOME/include/linux" -o native.o Native.c - MacOS:
cc -c -I "$JAVA_HOME/include" -I "$JAVA_HOME/include/darwin" -o native.o Native.c - Windows (msvc):
cl /I "%JAVA_HOME%\include" /I "%JAVA_HOME%\include\win32" /c Native.c
- Linux:
-
- Linux and MacOS:
ar rcs libNative.a native.o - Windows (msvc):
lib Native.obj
- Linux and MacOS:
-
native-image -jar HelloWorld.jar -H:CLibraryPath=.