Skip to main content
The Z3 Java API provides a high-level, object-oriented interface to Z3 for Java applications.

Prerequisites

  • Java Development Kit (JDK) 8 or later
  • Java IDE (Eclipse, IntelliJ IDEA, or VS Code) - optional but recommended

Installation Options

Download the latest Z3 release for your platform from the GitHub Releases page.
1

Download Z3

Download the appropriate package:
  • Windows: z3-x.x.x-x64-win.zip
  • Linux: z3-x.x.x-x64-glibc-x.x.zip
  • macOS: z3-x.x.x-x64-osx-x.x.zip
2

Extract Archive

Extract to a location on your system (e.g., C:\z3 on Windows or /opt/z3 on Linux/macOS).
3

Locate Files

The bin directory contains:
  • com.microsoft.z3.jar - Java API library
  • libz3.dll / libz3.so / libz3.dylib - Native Z3 library
  • libz3java.dll / libz3java.so / libz3java.dylib - Java JNI bridge

Option 2: Build from Source

Build Z3 with Java bindings enabled:
The Java bindings will be in the build directory:
  • com.microsoft.z3.jar
  • Native libraries (libz3java.* and libz3.*)

IDE Setup

Eclipse

1

Add Z3 JAR to Build Path

  1. Right-click project → Build Path → Configure Build Path
  2. Libraries tab → Add External JARs
  3. Select com.microsoft.z3.jar
  4. Click Apply and Close
2

Configure Native Library Path

Method 1: Native Library Location
  1. Expand Referenced Libraries → com.microsoft.z3.jar
  2. Right-click Native Library Location → Edit
  3. Select the Z3 bin folder
Method 2: VM Arguments
  1. Run → Run Configurations
  2. Arguments tab
  3. Add VM argument:

IntelliJ IDEA

1

Add Z3 JAR to Project

  1. File → Project Structure (Ctrl+Alt+Shift+S)
  2. Modules → Dependencies
  3. Click + → JARs or directories
  4. Select com.microsoft.z3.jar
2

Configure Native Library Path

  1. Run → Edit Configurations
  2. In VM options, add:

Visual Studio Code

1

Install Java Extension Pack

Install the Extension Pack for Java from the marketplace.
2

Configure Classpath

Create or edit .vscode/settings.json:
3

Configure Native Library Path

Create or edit .vscode/launch.json:

Command-Line Setup

Compiling

Running

Verify Installation

Create a test file TestZ3.java:
TestZ3.java
Compile and run:
Expected output:

Maven/Gradle Setup

Maven

Add Z3 as a system dependency in pom.xml:
pom.xml
Place com.microsoft.z3.jar in your project’s lib directory, and configure the native library path in your IDE or command line.

Gradle

Add to build.gradle:
build.gradle

Troubleshooting

ClassNotFoundException

Solution:
  • Verify com.microsoft.z3.jar is in your classpath
  • Check IDE configuration (Project Properties → Java Build Path)
  • Ensure proper classpath separator (: on Unix, ; on Windows)

UnsatisfiedLinkError

Solution:
  • Set java.library.path VM argument to Z3 bin directory
  • On Linux: Set LD_LIBRARY_PATH
  • On macOS: Set DYLD_LIBRARY_PATH
  • On Windows: Add Z3 bin to PATH or use -Djava.library.path
  • Verify both libz3java.* and libz3.* files are present

ExceptionInInitializerError

Solution:
  • Ensure all Z3 files are from the same version
  • Verify compatible Java version (JDK 8+)
  • Check native library architecture matches JVM (32-bit vs 64-bit)

Platform-Specific Library Names

  • Windows: libz3.dll and libz3java.dll
  • Linux: libz3.so and libz3java.so
  • macOS: libz3.dylib and libz3java.dylib

Next Steps

Getting Started

Learn the basics of the Z3 Java API

API Reference

Explore the complete Java API documentation

IDE Setup Guide

Detailed IDE configuration instructions