Getting started
This page takes you from a fresh clone to a song, its lyrics and its cover art, made by three engines in one JVM. Then it shows what your own application needs.
What you need
Section titled “What you need”-
JDK 25, to build Fornax. Apps that use Fornax need Java 22 or newer, where the Foreign Function & Memory API is final (Kiln 0.1.0 itself needs 25).
-
CMake, Ninja and a C++17 compiler, to build the engines.
-
The SDK for your GPU backend. For Vulkan, the Vulkan headers,
glslcand SPIRV-Headers. On Fedora:Terminal window sudo dnf install vulkan-headers vulkan-loader-devel glslc spirv-headers-develChoosing a GPU backend lists what HIP, CUDA and Metal need.
-
A GPU driver. On Linux, your GPU’s Vulkan driver: desktop Fedora and Ubuntu have it already. If not, follow Installing GPU drivers. Macs need nothing.
-
A way to download weights: the
fornaxcommand (built in step 3 below, or installed by Fornax Studio), or the Hugging Face CLI (hf). Both use the Hugging Face cache.
Build and run
Section titled “Build and run”-
Build the native libraries.
Terminal window git clone https://github.com/liberation-data/fornax.git && cd fornaxnative/build.sh vulkan # or hip | cuda | metal | cpunative/build.shclones each engine at the commit pinned innative/engines.propertiesintoengines-src/, applies Fornax’s patches, and writes one library per engine tobuild/native/<os>-<arch>-<backend>/, for examplebuild/native/linux-x86_64-vulkan/libfornax_llama.so. The first build takes a while.To build only some engines, list them after the backend:
native/build.sh vulkan llama tts. The engines arellama,tts,sd,acestep,yue2,whisperanddemucs. -
Build the Java modules.
Terminal window ./gradlew buildThe Gradle build points the examples and tests at
build/native/<os>-<arch>-vulkan/. For another backend, add-Pfornax.backend=hip(orcuda,metal,cpu) to any Gradle command. -
Fetch the weights for the demo.
Terminal window ./gradlew :fornax-cli:installDist # the fornax commandexport PATH="$PWD/fornax-cli/build/install/fornax-cli/bin:$PATH"fornax pull qwen3-4b # Qwen3 4B Instructfornax pull ace-step # ACE-Step 1.5 turbo and its 4B lyric LM: four filesfornax pull flux2-klein # FLUX.2 [klein]: three files, from three reposIf Fornax Studio has installed
fornaxfor you, skip the first two lines. Or fetch the same files with the Hugging Face CLI:Terminal window hf download unsloth/Qwen3-4B-Instruct-2507-GGUF Qwen3-4B-Instruct-2507-Q4_K_M.ggufhf download Serveurperso/ACE-Step-1.5-GGUF acestep-5Hz-lm-4B-Q8_0.gguf Qwen3-Embedding-0.6B-Q8_0.gguf \acestep-v15-turbo-Q8_0.gguf vae-BF16.ggufhf download black-forest-labs/FLUX.2-klein-base-4b-fp8 flux-2-klein-base-4b-fp8.safetensorshf download Comfy-Org/flux2-dev split_files/vae/flux2-vae.safetensorshf download Comfy-Org/z_image_turbo split_files/text_encoders/qwen_3_4b.safetensorsBoth put the files in the Hugging Face cache, so either can fetch what the other started, and nothing is stored twice. See Finding weights for where Fornax looks.
-
Run the demo.
Terminal window ./gradlew singleOne Java program has Qwen3 4B write a short country song, ACE-Step 1.5 sing it, and FLUX.2 [klein] paint its cover. It writes
single/single.wav,single/cover.pngandsingle/lyrics.txt. Pass your own idea with--args='out-dir "what the song is about"'.
More examples
Section titled “More examples”Each example is a Gradle task in fornax-examples. Model options are passed as -P properties.
./gradlew chat --args='"Write a haiku about a fornax"'./gradlew speak --args='out.wav "Hello from the JVM" bm_george' # -Pmodel=zonos3|lfm3-audio|chatterbox-turbo|..../gradlew image --args='klein out.png "a neon sign that says FORNAX"' -Psteps=12 -Pwidth=768 -Pheight=768./gradlew song --args='song.wav' # -Pdit=xl-turbo for the larger model./gradlew yue2 --args='yue2-song.wav'./gradlew video --args='clip.mp4 "a potter at a wheel, warm light"'The song examples read the requests in fornax-examples/src/main/resources/requests/; pass your own JSON as a second
argument. Each guide lists the weights its example needs.
Finding weights
Section titled “Finding weights”HfCache finds files that fornax pull or hf download has already put in the Hugging Face cache. It looks in
HF_HUB_CACHE, then $HF_HOME/hub, then ~/.cache/huggingface/hub. To download from Java as well, or to find a
whole model set’s files at once, use FornaxHub (see Downloading models).
import org.liberationdata.fornax.HfCache;
import java.nio.file.Path;import java.util.Optional;
// The file inside any downloaded snapshot of the repository, if there is one.Optional<Path> maybe = HfCache.find("unsloth/Qwen3-4B-Instruct-2507-GGUF", "Qwen3-4B-Instruct-2507-Q4_K_M.gguf");
// The same, or an IllegalStateException that names the hf download command to run.Path gguf = HfCache.require("unsloth/Qwen3-4B-Instruct-2507-GGUF", "Qwen3-4B-Instruct-2507-Q4_K_M.gguf");
// The first of several (repository, path) pairs that is present.Path encoder = HfCache.requireAny( "Comfy-Org/Qwen-Image_ComfyUI", "split_files/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors", "Comfy-Org/HunyuanVideo_1.5_repackaged", "split_files/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors");You don’t have to use it: every model class takes plain file paths.
In your own application
Section titled “In your own application”Your app needs the Fornax modules on its classpath, the native libraries where Fornax can find them, and permission to make native calls.
java -Dfornax.library.path=build/native/linux-x86_64-vulkan \ --enable-native-access=ALL-UNNAMED -jar your-app.jarFornax looks for each library (libfornax_llama.so, or .dylib on macOS) in this order:
-Dfornax.<name>.lib=<file>: an exact file, for example-Dfornax.fornax_llama.lib=/opt/fornax/libfornax_llama.so;- each directory in
-Dfornax.library.path(separated by your platform’s path separator); - each directory in the
FORNAX_LIBRARY_PATHenvironment variable; - a Fornax natives jar on the classpath (see Maven and Gradle);
- the platform loader’s path (
LD_LIBRARY_PATH,DYLD_LIBRARY_PATHand the system directories).
If it finds none, the first use of that engine’s model class fails with an UnsatisfiedLinkError that says where it
looked.
Set FORNAX_VERBOSE=1 to see the engines’ own logs; they are quiet by default, apart from errors.
Fornax Studio
Section titled “Fornax Studio”Fornax Studio is a desktop app around Fornax: chat with a GGUF model
and watch the tokens per second, watch it call tools, make an image or a song, and see what is loaded and how much
memory it holds. It runs Fornax in a JVM of its own, with its own Java, and finds models in your Hugging Face cache.
Models aren’t included. Choose Install fornax command from Studio’s menu to put fornax on your
PATH (coming in the next Fornax Studio release), then fetch them with fornax pull <alias>, such as
fornax pull qwen3-4b. Or use hf download as above: Studio, fornax and hf share the one cache.
The latest release is alpha 0.1.0:
- macOS, Apple silicon (.dmg) 197 MB
- macOS, Intel (.dmg) 207 MB
- Linux x64, Debian / Ubuntu (.deb) 194 MB
- Linux x64, Fedora / RHEL (.rpm) 164 MB