Skip to main content

Installation

This guide will walk you through adding Sava to your Java project using Gradle.

Prerequisites

Before installing Sava, ensure you have:
  • Java 21 or later - Sava requires modern Java features
  • Gradle - For dependency management (Maven support coming soon)
  • GitHub Account - Required for accessing Sava packages
Sava is distributed via GitHub Package Repository and requires authentication to download dependencies.

Setup Instructions

1

Generate a GitHub Token

You’ll need a GitHub personal access token with the read:packages scope.
  1. Go to GitHub Settings > Tokens
  2. Click “Generate new token (classic)”
  3. Give it a descriptive name like “Sava Package Access”
  4. Select the read:packages scope
  5. Click “Generate token”
  6. Copy the token immediately (you won’t be able to see it again)
Keep your token secure! Never commit it to version control.
2

Configure Gradle Credentials

Add your GitHub credentials to ~/.gradle/gradle.properties:
savaGithubPackagesUsername=YOUR_GITHUB_USERNAME
savaGithubPackagesPassword=YOUR_GITHUB_TOKEN
Replace YOUR_GITHUB_USERNAME with your GitHub username and YOUR_GITHUB_TOKEN with the token you just generated.
Alternatively, you can set these as environment variables:
  • ORG_GRADLE_PROJECT_savaGithubPackagesUsername
  • ORG_GRADLE_PROJECT_savaGithubPackagesPassword
3

Configure Repository Access

Add the Sava repository to your settings.gradle.kts:
settings.gradle.kts
pluginManagement {
  repositories {
    gradlePluginPortal()
    mavenCentral()
    
    val gprUser = providers.gradleProperty("savaGithubPackagesUsername")
      .orElse(providers.environmentVariable("ORG_GRADLE_PROJECT_savaGithubPackagesUsername"))
      .orElse(providers.environmentVariable("GITHUB_ACTOR"))
      .orNull
    
    val gprToken = providers.gradleProperty("savaGithubPackagesPassword")
      .orElse(providers.environmentVariable("ORG_GRADLE_PROJECT_savaGithubPackagesPassword"))
      .orElse(providers.environmentVariable("GITHUB_TOKEN"))
      .orNull
    
    if (!gprUser.isNullOrBlank() && !gprToken.isNullOrBlank()) {
      maven {
        url = uri("https://maven.pkg.github.com/sava-software/sava-build")
        credentials {
          username = gprUser
          password = gprToken
        }
      }
    }
  }
}

plugins {
  id("software.sava.build") version "21.3.4"
}
4

Add Dependencies

Choose the Sava modules you need and add them to your build.gradle.kts:
build.gradle.kts
dependencies {
  // Core module: Essential Solana types, crypto, and encoding
  implementation("software.sava:sava-core:VERSION")
  
  // RPC module: HTTP and WebSocket clients for Solana RPC
  implementation("software.sava:sava-rpc:VERSION")
}
Check the GitHub releases page for the latest version number.
5

Sync and Verify

Sync your Gradle project to download dependencies:
./gradlew build
If everything is configured correctly, Gradle will download Sava and its dependencies.

Available Modules

sava-core

The core module provides fundamental Solana functionality:
  • Cryptography: Ed25519 key generation, signing, and verification
  • Encoding: Base58, Base64, and Borsh serialization
  • Accounts: PublicKey and Signer implementations
  • Transactions: Transaction building and serialization
  • Programs: Common Solana program interfaces
  • Tokens: SPL token types and utilities
implementation("software.sava:sava-core:VERSION")

sava-rpc

The RPC module provides clients for interacting with Solana nodes:
  • HTTP Client: Complete Solana JSON-RPC API implementation
  • WebSocket Client: Real-time account and transaction subscriptions
  • Type-safe Responses: Strongly-typed response parsing
  • Async APIs: CompletableFuture-based async operations
  • Network Helpers: Pre-configured endpoints for mainnet, testnet, and devnet
implementation("software.sava:sava-rpc:VERSION")
The sava-rpc module depends on sava-core, so you don’t need to explicitly include both if you’re using RPC functionality.

Module Selection Guide

Choose modules based on your use case:
Use CaseRequired Modules
Building transactions offlinesava-core
Querying blockchain datasava-core, sava-rpc
Building a trading botsava-core, sava-rpc
Working with tokenssava-core
Real-time account monitoringsava-core, sava-rpc

Troubleshooting

Authentication Errors

If you see authentication errors when syncing:
  1. Verify your GitHub token has the read:packages scope
  2. Check that your username and token are correctly set in gradle.properties
  3. Ensure there are no extra spaces in the credentials

Package Not Found

If Gradle can’t find Sava packages:
  1. Verify the repository URL is correct in settings.gradle.kts
  2. Check that you’re using a valid version number
  3. Ensure your GitHub token hasn’t expired

Build Errors

If you encounter build errors:
  1. Verify you’re using Java 21 or later: java -version
  2. Clean and rebuild: ./gradlew clean build
  3. Check for conflicting dependencies

Next Steps

Now that you’ve installed Sava, check out the Quickstart Guide to start building your first Solana application with Java.

Build docs developers (and LLMs) love