Skip to content

CLI Reference

The nativify command-line tool protects a JAR and writes a new one. Build it first (see Building from source); the launcher lands at dist/bin/nativify (dist\bin\nativify.bat on Windows).

dist/bin/nativify -i <input.jar> -o <output.jar> [options]

Required options

Flag Long form Description
-i --inputJar <file> Input JAR to protect.
-o --outputJar <file> Output JAR to write.

Common options

Flag Long form Description
-compileFor <list> Target platforms to build native libraries for (comma-separated). Without this, no native libraries are produced.
-enable <list> Enable features and obfuscation passes (comma-separated). See Configuration.
-c --config <file> JSON config file supplying defaults for these options.
-v --verbose Verbose progress output.
-help Print the help page.

Toolchain & output options

Flag Description Default
-llvmDir <dir> LLVM installation bin directory. Auto-detected via llvm-config
-outputDir <dir> Where to place the built native libraries. Temp dir; libraries are embedded in the output JAR
-ll <dir> / --irOutput <dir> Also dump the generated LLVM IR to this folder. Off
-skipIROpt Skip the LLVM IR optimization step. Off (auto-enabled if an LLVM version mismatch is detected)
-compilerFlags <list> Extra C compiler flags (comma-separated), e.g. -I/include/path,-DFLAG. None
-linkerFlags <list> Extra linker flags (comma-separated), e.g. --sysroot=/path,-L/lib/path. None
-lib <list> Extra JARs to index for type resolution only — not compiled, not added to the output (comma-separated paths). None

Flag style

-i, -o, -ll, -c, -v accept both the short and --long form. The remaining options (-compileFor, -enable, -llvmDir, …) use the single-dash form shown above.

Target platforms

-compileFor accepts a comma-separated list of os-arch targets, or a bare os that expands to all common architectures for that OS:

You pass Nativify builds
windows windows-x86_64, windows-aarch64
linux linux-x86_64, linux-aarch64, linux-arm, linux-x86
android android-aarch64, android-x86_64, android-arm
macos macos-x86_64, macos-aarch64

Or name an explicit target: windows-x86_64, linux-aarch64, android-aarch64, etc.

# One architecture
-compileFor windows-x86_64

# Several explicit targets
-compileFor linux-x86_64,linux-aarch64,windows-x86_64

# All architectures for an OS
-compileFor linux

Partial-platform behaviour

If a requested target fails to build (e.g. a missing cross-toolchain), the whole job fails rather than shipping a JAR that references a missing library. Request only the platforms you can build, and ship a JAR per platform group if needed.

Examples

Protect annotated methods for one platform

dist/bin/nativify -i app.jar -o app-protected.jar -compileFor windows-x86_64

Enable obfuscation passes

dist/bin/nativify -i app.jar -o app-protected.jar \
  -compileFor linux-x86_64 \
  -enable native-llvm-passes-bogus-control-flow,native-llvm-passes-substitution,native-llvm-passes-string-encryption

Protect every eligible method (no annotation needed)

dist/bin/nativify -i app.jar -o app-protected.jar \
  -compileFor windows-x86_64 \
  -enable disable-annotation-check

Point at a specific LLVM install

dist/bin/nativify -i app.jar -o app-protected.jar \
  -compileFor windows-x86_64 \
  -llvmDir "C:\Program Files\LLVM\bin"

Save the generated LLVM IR (for inspection)

dist/bin/nativify -i app.jar -o app-protected.jar \
  -compileFor linux-x86_64 \
  -ll ./ir-output

Exit codes

Code Meaning
0 Success — the output JAR was written and verified.
1 Failure — compilation, a requested platform, or packaging failed. No output JAR is shipped.

See also