Same engines
The native runners themselves
Fornax4j calls llama.cpp, stable-diffusion.cpp, acestep.cpp, yue2.cpp, whisper.cpp and stems.cpp directly: the same C/C++ engines the CLIs and servers use, so you get their speed and their model support.

Open generative models for the JVM
Call models as plain Java methods, on your GPU, inside your JVM.
NewWatch · 2:31: Fornax4j in two minutesEarly · Apache 2.0 · a Liberation Data project · Download Fornax Studio
Zero overhead
Straight from the JVM to the GPU.
Fornax4j runs open-weight models in-process, through Java’s Foreign Function & Memory API: language and vision models, speech, images, songs and video, for business, industrial, medical and creative work, or anywhere a specialized model earns its keep. A model is an object, a generation is a method call, and the weights stay on your GPU between calls. There is no Python, no model server, no HTTP, no JSON round trip and no second process.


Fornax4j in two minutes: open generative models inside your JVM. With captions.
Same engines
Fornax4j calls llama.cpp, stable-diffusion.cpp, acestep.cpp, yue2.cpp, whisper.cpp and stems.cpp directly: the same C/C++ engines the CLIs and servers use, so you get their speed and their model support.
Vulkan today
Vulkan on AMD, Intel and NVIDIA. The same build script knows ROCm, CUDA and Metal, and your Java code doesn’t change when you switch.
One process
A Fornax4j call is a native function call. Weights stay resident between calls, and tokens stream back to a Java callback as they are produced.
Plain Java API
Open a model in a try-with-resources block, call it as often as you like, and close it to give the memory back.
AutoCloseable: weights are freed on close().System.out::print.chatJson: OpenAI-style messages and tools in, tool_calls out.BufferedImage.// The weights load onto the GPU once, and stay there until close()
try (var llm = new LlamaModel("Qwen3-4B-Instruct-2507-Q4_K_M.gguf")) {
// Tokens stream to your callback as they are produced
llm.chat(List.of(Message.user("Name a country song about a robot.")),
Options.DEFAULT, System.out::print);
}// OpenAI-style messages and tools in, an OpenAI-style message out
String res = llm.chatJson("""
{"messages": [{"role": "user",
"content": "What's the weather in Nashville right now?"}],
"tools": [{"type": "function", "function": {
"name": "get_weather", "description": "Current weather for a city",
"parameters": {"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]}}}],
"temperature": 0, "max_tokens": 128, "seed": 1}""",
null); // or a callback, to stream
// res has content, reasoning_content and tool_calls:
// here, finish_reason "tool_calls" and get_weather for Nashvilletry (var songs = new AceStepModel(lm, textEncoder, dit, vae, true)) {
songs.generate(requestJson).audio().writeWav(new File("song.wav"));
}try (var images = new DiffusionModel(DiffusionModel.Config.builder()
.diffusionModel(flux).vae(vae).llm(textEncoder).build())) {
BufferedImage img = images.generate(
new DiffusionModel.Request("a neon sign", 1024, 1024, 20, 4.0, 7)).get(0);
}A catalogue name or a Hugging Face reference downloads into your Hugging Face cache on first use; a file path never downloads anything.
Engines and models
Each module binds one engine. Use one, or put several in the same JVM.
Text
on llama.cpp
Any GGUF language model, vision models that read images, and embeddings and reranking for search.
Speech
on llama.cpp
Text to speech, with built-in voices or a reference clip.
Images
Diffusion models, including image editing.
Songs
on acestep.cpp
Songs with vocals and lyrics, up to several minutes long.
Songs
on yue2.cpp
Songs, from the engine’s own JSON request.
Transcripts
on whisper.cpp
Speech to text, with a start and end for every word.
Stems
on stems.cpp
A song split into vocals and backing, or drums, bass, other and vocals.
Check each model’s license before you use what it makes. Some are non-commercial: YuE2’s weights are CC BY-NC 4.0, for example.
Measured
A 4B model streams about 70 tokens a second into a Java callback. A one-minute song takes 15 seconds, 55 seconds of speech is transcribed word by word in under two, and a whole track splits into four stems in 26. All from plain Java calls: no Python, no server.
Measured on our reference machine, a Ryzen AI Max+ 395 laptop on Vulkan. Benchmarks has the commands behind the chat, image and song figures, and sets them against the engine’s own tool and ComfyUI; the guides give the rest.
| Model | Result |
|---|---|
| Qwen3 4B Instruct (Q4_K_M) | ~70 tokens/s |
| ACE-Step 1.5 XL turbo | 3 min 20 s song in 57 s |
| ACE-Step 1.5 turbo | 60 s song in ~15 s |
| YuE2 3B (Q8_0) | 60 s song in ~60 s |
| FLUX.2 [klein] base 4B (fp8) | 768×768, 12 steps in ~130 s |
| Qwen-Image 2512 (fp8) | 1024×1024, 20 steps in ~13 min |
| Whisper large-v3-turbo (q5_0) | 55 s of speech in 1.8 s, timed word by word |
| HTDemucs v4 | 3 min 9 s song into four stems in 26 s |
Against ComfyUI
ACE-Step 1.5 turbo with its 4B LM, writing a 60 s song, on the same machine. Cold is the first run with nothing loaded, weights included. Warm is the second run with the weights resident (seed + 1, so ComfyUI doesn’t return its cached result).
Not quite like for like: ComfyUI ran the bf16 safetensors DiT, Fornax4j the GGUF Q8_0 weights. One run each, from fornax-bench.
Runs on
One Java API, and the native libraries for your platform. Vulkan, ROCm and Metal run the full test suite every night. The natives jar you add picks the backend; for ROCm, you build the engines once. Set up on your platform has the steps for each.
Fornax Studio
Fornax Studio is a desktop app around Fornax4j: 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 Fornax4j in a JVM of its own, with its own Java, and finds the models in your Hugging Face cache.
![Fornax Studio in its dark theme with two windows on its desktop. Behind, the Chat window: Qwen3 4B Instruct answering a request for a haiku about a fornax and one sentence on what a fornax is for, at 68.7 tokens a second, with its time to the first token and token counts. In front, overlapping it, the Image window: FLUX.2 [klein] with its prompt, size and steps, and the image it made, a fornax's orange fire beside shelves of stoneware jars, generated in 2 minutes 17 seconds over 12 steps](/_astro/studio-desktop.BbRS_0us_27qYbE.webp)
Download Fornax Studio. alpha 0.3.2Models are not included: fetch them with fornax pull or the Hugging Face CLI, as in Getting started.
Open the .dmg and drag Fornax Studio to Applications.
It needs your GPU's Vulkan driver. A software centre can't open a local package by double-click, so use the terminal for a downloaded file too.
Thanks for trying Fornax Studio. While it downloads: if Fornax4j is useful to you, a star on GitHub is how other Java developers find it.
★ Star Fornax4j on GitHubEvery release, and its notes, are on GitHub.
How it works
Each engine is built into a single shared library with its own ggml linked in statically and kept private. The engines pin different ggml versions, and this is what lets several of them share one process.
Has a key/value C API, so fornax-sd binds it directly.
Its C API passes structs by value and is mid-migration to a new batch API, so fornax-llama binds a small, stable C layer instead.
C++ only, so each gets a C layer of about a hundred lines: a JSON request in, PCM audio out.
LlamaModel.chatJson takes messages and tools in OpenAI’s format and returns a message with content, reasoning_content and tool_calls. It uses the model’s own chat template and tool-call format, with the same templates and parsers as llama-server.
Keeps models resident between uses, the way ComfyUI does. It unloads idle models least recently used first to stay within a memory budget, can unload after an idle timeout, and gives each model one user at a time.
The Java is the same for every backend. native/build.sh builds the libraries for the one you name.
A long GPU dispatch can trip a laptop driver’s compute timeout, so ACE-Step audio is decoded in 512-frame tiles. Tune it with FORNAX_ACESTEP_VAE_CHUNK.
Set FORNAX_VERBOSE=1 to see what llama.cpp, stable-diffusion.cpp and friends print.
Embabel
Embabel Agent plans with goals and actions on the JVM. Fornax4j runs local models in the same process: chat and tool calls, vision, embeddings, speech, images, songs and video. Afornax-embabel module, to give Embabel's agents those models, is in progress.
Quick start
You need Java 22 or newer, and on Linux your GPU’s Vulkan driver, which desktop installs already have (if not: Installing GPU drivers). Macs need nothing more.
// build.gradle.kts
plugins { application }
repositories { mavenCentral() }
val natives = // the natives jar for the OS and arch building it
if (System.getProperty("os.name").startsWith("Mac")) "macos-aarch64-metal" else "linux-x86_64-vulkan"
dependencies {
implementation(platform("org.fornax4j:fornax-bom:0.3.3"))
implementation("org.fornax4j:fornax-llama")
runtimeOnly("org.fornax4j:fornax-natives-$natives")
}
application {
mainClass = "Hello"
applicationDefaultJvmArgs = listOf("--enable-native-access=ALL-UNNAMED")
}<!-- pom.xml: Maven picks the natives jar for the machine building it -->
<properties>
<maven.compiler.release>22</maven.compiler.release>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.fornax4j</groupId>
<artifactId>fornax-bom</artifactId>
<version>0.3.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.fornax4j</groupId>
<artifactId>fornax-llama</artifactId>
</dependency>
<dependency>
<groupId>org.fornax4j</groupId>
<artifactId>fornax-natives</artifactId>
<type>pom</type>
<scope>runtime</scope>
</dependency>
</dependencies>One natives jar holds every engine’s libraries, so there’s no native build. Fornax4j unpacks the one it needs into its cache the first time it loads.
// src/main/java/Hello.java
import org.liberationdata.fornax.llama.LlamaModel;
import org.liberationdata.fornax.llama.LlamaModel.*;
import java.util.List;
public class Hello {
public static void main(String[] args) {
// Downloaded on first use, then loaded onto the GPU
try (var llm = new LlamaModel("unsloth/Qwen3-4B-Instruct-2507-GGUF:Q4_K_M")) {
llm.chat(List.of(Message.user("Write a haiku about a fornax. Just the haiku.")),
Options.DEFAULT, System.out::print);
}
}
}The first run downloads Qwen3 4B (2.5 GB) into the Hugging Face cache, which hf, Fornax Studio and the fornax command share. To fetch it ahead of time: fornax pull qwen3-4b.
./gradlew runMAVEN_OPTS=--enable-native-access=ALL-UNNAMED mvn -q compile exec:java -Dexec.mainClass=Hello$ ./gradlew run
Fornax breathes warm flame—
crackling, ancient, deep in stone,
life forged in stillness.A real run on a Radeon 8060S: loaded in 0.7 s, then 58 tokens a second, printed as they come. The JVM needs --enable-native-access=ALL-UNNAMED: Gradle’s application block passes it, and Maven’s exec:java runs the app inside Maven’s own JVM, so it goes in MAVEN_OPTS. samples/hello-fornax is this app, ready to copy.
try (var tts = new TtsModel("kokoro")) { // a catalogue alias
tts.speak("Hello from the JVM.", "am_michael").writeWav(new File("hello.wav"));
}var config = DiffusionModel.Config.builder().model("flux2-klein").build();
try (var images = new DiffusionModel(config)) {
BufferedImage img = images.generate(
new DiffusionModel.Request("a neon sign that says FORNAX", 1024, 1024, 20, 4.0, 7)).get(0);
ImageIO.write(img, "png", new File("sign.png"));
}try (var songs = new AceStepModel("ace-step")) { // its four files, fetched on first use
songs.generate(requestJson).audio().writeWav(new File("song.wav"));
}try (var whisper = new WhisperModel("whisper-base.en")) {
Transcript t = whisper.transcribe(Audio.readWav(new File("hello.wav")));
System.out.println(t.text()); // and t.segments(), with word timings
}That’s the whole shape. Add fornax-tts, fornax-sd, fornax-acestep or fornax-whisper next to fornax-llama, with no version and no second natives jar. Each takes a catalogue name or a Hugging Face reference. The guides go further. For ROCm or CUDA, Set up on your platform has the steps.
The fornax command chats, makes images and songs, speaks, transcribes and serves models, with no project to set up. More about installing it. Claude Code can run it for you too, with the Fornax4j skills.
Linux x86_64 (Vulkan) and Apple silicon Macs (Metal). It needs no root, checks the download against the release’s SHA256SUMS, and installs into your home folder. It uses the Java 22 or newer you have, and if there’s none, tells you how to get one. Run it again to update. Or read it first.
JBang runs Java programs without installing them, as npx does for JavaScript. This one command fetches fornax, and Java too if you have none.
Roadmap
fornax-embabel: an Embabel Agent LlmService and LocalModelSource.mlx-c.Flow streaming.Things on the JVM are about to heat up
Open models as Java objects, on your own GPU. Fornax4j is early: try it, and tell us what breaks.