Practical overview
When it fits
Use it when a Java application needs library-level access to Solana RPC for account queries or transaction workflows.
Who it is for
- Java developers integrating applications with Solana RPC.
- Teams building Java wallet or transaction utilities for SOL or SPL tokens.
Documented uses
- Query a Solana account balance.
- Generate a keypair and derive its public address.
- Construct, sign and submit SOL or SPL-token transactions.
- Calculate associated token addresses and work with nonce accounts.
Requirements & limits
The repository is public and identifies the project as MIT-licensed open source.
- Java 8 or later is listed as a requirement.
- The README names bitcoinj, OkHttp and Moshi as dependencies.
- The examples use TESTNET for balance and SOL-transfer calls and DEVNET for nonce-account creation.
- The project provides Java library code rather than a hosted end-user wallet.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Query a Solana account balance with solanaj
Read an account balance through a TESTNET RPC client.
Before you start
- Java 8+
- The solanaj library and its listed dependencies: bitcoinj, OkHttp, and Moshi
- A Solana public key to query
Steps
Create an
RpcClientconfigured withCluster.TESTNET.Create a
PublicKeyfor the account address.Call
client.getApi().getBalance(publicKey)and store the returned value as along.
Expected outcome
The example obtains the account balance as a `long` from the TESTNET RPC API.
Guide limitations
- The example does not document error handling or RPC endpoint configuration.
Construct and submit a lamport transfer on TESTNET
Build a transfer instruction, sign it with an account, and submit the transaction using the TESTNET RPC client.
Before you start
- Java 8+
- The solanaj library and its listed dependencies: bitcoinj, OkHttp, and Moshi
- The sender's secret key and source and destination public keys
Steps
Create an
RpcClientconfigured withCluster.TESTNET, then constructPublicKeyobjects for the sender and recipient.Create an
Accountfrom the sender's secret key and aTransaction.Add a
SystemProgram.transfer(fromPublicKey, toPublicKey, lamports)instruction to the transaction.Submit it with
client.getApi().sendTransaction(transaction, signer)and retain the returned signature.
Expected outcome
The example submits a signed lamport transfer and returns a transaction signature.
Guide limitations
- The example does not document error handling or how to obtain and secure the sender's secret key.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 15 October 2026
- Original website title
- dongyuhao66/solanaj · Official homepage title · retained in its source language

