Quickstart · 1.0.0-rc01
The quickstart parses and validates IBANs, checks national check digits, creates an IBAN, validates a BBAN field and a BIC, and creates an EPC QR code payload and a SEPA Creditor Identifier. All inputs and artifact and Maven plugin versions are fixed, so the output is the same on every machine. The values are the public examples of the SWIFT registry, the EPC and the Deutsche Bundesbank; do not use them for real payments.
1. Prepare the project directory
Requirements: JDK 21, Maven 3.9.9, and a POSIX shell with mktemp (Linux or macOS). The first Maven build needs network access to download the pololei artifacts from Maven Central. pololei has no runtime dependencies and never needs a network connection at runtime.
All shell steps in this quickstart use the same terminal session.
set -eu
java -version
mvn -version
POLOLEI_QUICKSTART_DIR=$(mktemp -d "${TMPDIR:-/tmp}/pololei-quickstart.XXXXXX")
mkdir -p "$POLOLEI_QUICKSTART_DIR/app/src/main/java/example"
cd "$POLOLEI_QUICKSTART_DIR/app"
Keep the printed temporary directory path if you want to return to the example later; echo "$POLOLEI_QUICKSTART_DIR" shows it.
2. Create the application POM
Save the following as pom.xml in the app directory created above. The application has no parent POM and uses the exact release version 1.0.0-rc01 from Maven Central.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>pololei-quickstart</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>io.github.nalukit</groupId>
<artifactId>pololei</artifactId>
<version>1.0.0-rc01</version>
</dependency>
<dependency>
<groupId>io.github.nalukit</groupId>
<artifactId>pololei-epc</artifactId>
<version>1.0.0-rc01</version>
</dependency>
<dependency>
<groupId>io.github.nalukit</groupId>
<artifactId>pololei-creditor</artifactId>
<version>1.0.0-rc01</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.7.0</version>
</plugin>
</plugins>
</build>
</project>
3. Create the application
Save this complete class as src/main/java/example/Quickstart.java in the same app directory. No imports or helper objects are omitted.
package example;
import io.github.nalukit.pololei.Bban;
import io.github.nalukit.pololei.Bic;
import io.github.nalukit.pololei.Iban;
import io.github.nalukit.pololei.IbanValidator;
import io.github.nalukit.pololei.NationalCheckMode;
import io.github.nalukit.pololei.ValidationResult;
import io.github.nalukit.pololei.creditor.CreditorIdentifier;
import io.github.nalukit.pololei.epc.EpcQrPayload;
import io.github.nalukit.pololei.error.IbanError;
import io.github.nalukit.pololei.registry.BbanField;
import java.math.BigDecimal;
public final class Quickstart {
public static void main(String[] args) {
// parse: whitespace and lower case letters are accepted
Iban iban = Iban.parse("de89 3704 0044 0532 0130 00");
System.out.println("IBAN: " + iban + " / " + iban.toPrintFormat());
System.out.println("fields: bank " + iban.bankIdentifier().orElseThrow()
+ ", account " + iban.field(BbanField.ACCOUNT_NUMBER).orElseThrow()
+ ", SEPA " + iban.isSepa());
// validate without exceptions
ValidationResult<Iban, IbanError> invalid = Iban.validate("DE88 3704 0044 0532 0130 00");
System.out.println("invalid: " + invalid.error().orElseThrow() + " - " + invalid.message().orElseThrow());
// national check digits (French RIB key)
IbanValidator validator = IbanValidator.standard()
.nationalCheck(NationalCheckMode.IF_SUPPORTED);
String wrongRibKey = "FR8420041010050500013M02607";
System.out.println("national: " + validator.validate(wrongRibKey).error().orElseThrow()
+ ", Iban.isValid=" + Iban.isValid(wrongRibKey));
// create an IBAN, calculating IBAN and national check digits
Iban built = Iban.builder()
.countryCode("FR")
.bankIdentifier("20041")
.branchIdentifier("01005")
.field(BbanField.ACCOUNT_NUMBER, "0500013M026")
.nationalCheckDigits(true)
.build();
System.out.println("built: " + built + ", national check "
+ validator.validate(built.toString()).nationalCheck());
// validate a single BBAN field
var field = Bban.validateField("DE", BbanField.BANK_IDENTIFIER, "3704004X");
System.out.println("field: " + field.error().orElseThrow() + " at position "
+ field.position().orElseThrow());
// BIC
Bic bic = Bic.parse("DEUTDEFF500");
System.out.println("BIC: " + bic + ", primary office " + bic.primaryOffice()
+ ", branch " + bic.branchCode().orElseThrow());
// EPC QR code payload (module pololei-epc)
EpcQrPayload payload = EpcQrPayload.builder()
.beneficiaryName("Red Cross of Belgium")
.iban(Iban.parse("BE72000000001616"))
.bic(Bic.parse("BPOTBEB1"))
.amount(new BigDecimal("1.00"))
.remittanceText("Urgency fund")
.build();
System.out.println("EPC: " + payload.lines().size() + " lines, " + payload.byteLength()
+ " bytes, " + payload.lines().get(7));
// SEPA Creditor Identifier (module pololei-creditor)
CreditorIdentifier ci = CreditorIdentifier.of("DE", null, "09999999999");
System.out.println("CI: " + ci + ", same creditor as A1B: "
+ ci.withBusinessCode("A1B").isSameCreditor(ci));
}
}
4. Compile and run
Still in the app directory:
mvn -B -ntp compile \
org.apache.maven.plugins:maven-dependency-plugin:3.7.0:copy-dependencies \
-DincludeScope=runtime
java -cp 'target/classes:target/dependency/*' example.Quickstart
Expected standard output (JVM diagnostics may additionally appear on standard error):
IBAN: DE89370400440532013000 / DE89 3704 0044 0532 0130 00
fields: bank 37040044, account 0532013000, SEPA true
invalid: INVALID_CHECK_DIGITS - check digits 88 are not valid
national: INVALID_NATIONAL_CHECK_DIGITS, Iban.isValid=true
built: FR1420041010050500013M02606, national check PASSED
field: INVALID_BBAN at position 8
BIC: DEUTDEFF500, primary office DEUTDEFF, branch 500
EPC: 11 lines, 80 bytes, EUR1
CI: DE98ZZZ09999999999, same creditor as A1B: true
orElseThrow() terminates the process with an exception if a result differs from the expected one. Once the application is compiled and the dependencies have been copied, the java command also works without network access.
Next steps
- Explore the complete API reference.
- Choose your modules.
- Migrate from iban4j or iban4g.