Skip to content

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.

  • 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, glslc and SPIRV-Headers. On Fedora:

    Terminal window
    sudo dnf install vulkan-headers vulkan-loader-devel glslc spirv-headers-devel

    Choosing 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 fornax command (built in step 3 below, or installed by Fornax Studio), or the Hugging Face CLI (hf). Both use the Hugging Face cache.

  1. Build the native libraries.

    Terminal window
    git clone https://github.com/liberation-data/fornax.git && cd fornax
    native/build.sh vulkan # or hip | cuda | metal | cpu

    native/build.sh clones each engine at the commit pinned in native/engines.properties into engines-src/, applies Fornax’s patches, and writes one library per engine to build/native/<os>-<arch>-<backend>/, for example build/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 are llama, tts, sd, acestep, yue2, whisper and demucs.

  2. Build the Java modules.

    Terminal window
    ./gradlew build

    The Gradle build points the examples and tests at build/native/<os>-<arch>-vulkan/. For another backend, add -Pfornax.backend=hip (or cuda, metal, cpu) to any Gradle command.

  3. Fetch the weights for the demo.

    Terminal window
    ./gradlew :fornax-cli:installDist # the fornax command
    export PATH="$PWD/fornax-cli/build/install/fornax-cli/bin:$PATH"
    fornax pull qwen3-4b # Qwen3 4B Instruct
    fornax pull ace-step # ACE-Step 1.5 turbo and its 4B lyric LM: four files
    fornax pull flux2-klein # FLUX.2 [klein]: three files, from three repos

    If Fornax Studio has installed fornax for 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.gguf
    hf 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.gguf
    hf download black-forest-labs/FLUX.2-klein-base-4b-fp8 flux-2-klein-base-4b-fp8.safetensors
    hf download Comfy-Org/flux2-dev split_files/vae/flux2-vae.safetensors
    hf download Comfy-Org/z_image_turbo split_files/text_encoders/qwen_3_4b.safetensors

    Both 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.

  4. Run the demo.

    Terminal window
    ./gradlew single

    One 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.png and single/lyrics.txt. Pass your own idea with --args='out-dir "what the song is about"'.

Each example is a Gradle task in fornax-examples. Model options are passed as -P properties.

Terminal window
./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.

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.

Your app needs the Fornax modules on its classpath, the native libraries where Fornax can find them, and permission to make native calls.

Terminal window
java -Dfornax.library.path=build/native/linux-x86_64-vulkan \
--enable-native-access=ALL-UNNAMED -jar your-app.jar

Fornax looks for each library (libfornax_llama.so, or .dylib on macOS) in this order:

  1. -Dfornax.<name>.lib=<file>: an exact file, for example -Dfornax.fornax_llama.lib=/opt/fornax/libfornax_llama.so;
  2. each directory in -Dfornax.library.path (separated by your platform’s path separator);
  3. each directory in the FORNAX_LIBRARY_PATH environment variable;
  4. a Fornax natives jar on the classpath (see Maven and Gradle);
  5. the platform loader’s path (LD_LIBRARY_PATH, DYLD_LIBRARY_PATH and 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 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.