Skip to content

πŸš€ Quick Start with Jot

This guide walks you through setting up a Java project with Jot, and interacting with the Polkadot blockchain.


πŸ“‹ Prerequisites

  • Java 21+
  • Maven 3.9+ or Gradle 7+
  • A Polkadot/Substrate node RPC endpoint (e.g., wss://rpc.polkadot.io)

βš™οΈ 1) Create a new project

Maven (quickstart archetype)

mvn archetype:generate \
  -DgroupId=com.example \
  -DartifactId=hello-jot \
  -DarchetypeArtifactId=maven-archetype-quickstart \
  -DinteractiveMode=false
cd hello-jot

Add Jot to your pom.xml:

<dependencies>
  <dependency>
    <groupId>com.method5</groupId>
    <artifactId>jot</artifactId>
    <version>1.0.1</version>
  </dependency>
</dependencies>

(Optional) Add the Maven Exec plugin so you can run main easily:

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>3.5.0</version>
      <configuration>
        <mainClass>com.example.HelloPolkadot</mainClass>
      </configuration>
    </plugin>
  </plugins>
</build>

Gradle (application template)

gradle init --type java-application
cd hello-jot

Add Jot to build.gradle.kts:

dependencies {
    implementation("com.method5:jot:1.0.1")
}

Ensure the application plugin has your main class:

plugins {
    application
}

application {
    mainClass.set("com.example.HelloPolkadot")
}

πŸ”Œ 2) Connect to a node (β€œHello Polkadot”)

Create src/main/java/com/example/HelloPolkadot.java:

package com.example;

import com.method5.jot.query.ChainRpc;
import com.method5.jot.query.SystemRpc;
import com.method5.jot.rpc.PolkadotWsClient;
import com.method5.jot.util.HexUtil;

public class HelloPolkadot {
    public static void main(String[] args) throws Exception {
        try (PolkadotWsClient rpc = new PolkadotWsClient("wss://polkadot.api.onfinality.io/public-ws")) {
            System.out.println("Connected to chain: " + SystemRpc.chain(rpc));
            System.out.println("Genesis hash: " + HexUtil.bytesToHex(ChainRpc.getGenesisBlockHash(rpc)));
        }
    }
}

Run it:

Maven

mvn -q compile exec:java

Gradle

./gradlew run

πŸ§ͺ 3) Where to go next

  • Review the README for most common usage examples.
  • Explore the jot-examples module for an additional 50+ runnable samples.
  • Browse the API Javadoc for JOT API information.
  • Build real apps on Polkadot in Java πŸš€

πŸ› οΈ Troubleshooting (quick)

  • Java version: Ensure java -version reports 21+.
  • WebSocket blocked: Some corporate networks/proxies block WSS. Try another network or a self-hosted node.
  • Native libs: If you see UnsatisfiedLinkError, ensure your runtime can load Jot’s native libs for your OS/arch. Check release notes for classifiers and verify java.library.path if needed.