Skip to main content
Version: 0.1

Getting Started with Java


To use the library, we recommend you update Rust to the latest stable version $ rustup update stable. Nightly should be fine but some changes might not be compatible.

Ensure you have installed the required dependencies for the library first. Then, you can also install the following programs:

  • Java & JDK (Make sure $JAVA_HOME env variable is set).
  • Gradle v4 or higher or Maven.
  • Cargo ndk (cargo install cargo-ndk).
  • Cargo fmt (rustup component add rustfmt).

Download or clone the repository:

git clone -b production


In a production setup, do not store passwords in the host's environment variables or in the source code. See our backup and security recommendations for production setups.


To build using the Java bindings, you will need:

  1. JNI Native library linking Rust to C, and then C to java native methods (.so , .dll or .dylib depending on your system).
  2. Java archive(Jar) containing native methods which call C code. (.jar).

Step 1: Creating the Native Library

Build the wallet library (this generates the java source code and JNI library file):

cargo build --release

You can find the generated binaries in


Compiling for Android requires additional compilation instructions.

You can find these instructions in Getting Started with Java for Android.

Step 2: Creating the Java Archive

Generating the source files and classes

After you complete step 1, you can find the Java generated source files under

If this step succeeds, you need to generate the jar file containing the newly generated Java source files.

Generating the jar

You can generate the jar file with your tool of preference. This guide provides examples for Gradle and Maven.


Make gradlew executable (chmod +x gradlew) if needed, then run the following commands from the project root:

./gradlew jar
mvn install

After running one of these commands, you can find the jar file at


You can find more information on using the library's java binding in the examples section.


./gradlew examples:java-app:test --info

### Maven

You can run the examples using Maven by running the following command:

mvn exec:exec

API Reference

You can find the references for the binding's API in the Java API Reference section.


Due to the fact that tje Java binding through C to Rust, there are a few limiting factors.

  • Classic builder patterns return a clone after each builder call since we can only pass back to C by reference in Rust as shown in the example below.
Builder builder1 = new Builder();
Builder builder2 = builder1.setValue(true);

// These are different instances, thus builder1 wont have the value set
assertNotEquals(builder1, builder2);