This document provides a formal, technical procedure for deploying and building the Bouncy Castle Crypto APIs on Ubuntu 22.04 using OpenJDK 25.
The build process requires a modern Java Development Kit. Follow these steps to manually install OpenJDK 25 and configure the system path.
# Download the OpenJDK Java 25 binary
wget https://download.java.net/java/GA/jdk25.0.1/2fbf10d8c78e40bd87641c434705079d/8/GPL/openjdk-25.0.1_linux-x64_bin.tar.gz
# Create installation directory and extract
sudo mkdir -p /opt/java
sudo tar -xzf openjdk-25.0.1_linux-x64_bin.tar.gz -C /opt/java
sudo mv /opt/java/jdk-25.0.1 /opt/java/jdk-25To ensure the system recognizes the new Java version, update your shell profile (e.g., ~/.bashrc).
export JAVA_HOME=/opt/java/jdk-25
export PATH=$PATH:$JAVA_HOME/bin
# (Optional) Multi-JDK Testing: Define paths for older JVMs to test compatibility
# export BC_JDK8=/path/to/java8
# export BC_JDK11=/path/to/java11
# export BC_JDK17=/path/to/java17
# export BC_JDK25=/path/to/java25Apply changes: source ~/.bashrc
Bouncy Castle relies on a separate repository for regression test data. Both must be cloned into the same parent directory.
mkdir bc-workspace && cd bc-workspace
git clone https://github.com/bcgit/bc-java.git
git clone https://github.com/bcgit/bc-test-data.gitNavigate to the project root and use the Gradle wrapper. The build supports skipping tests for rapid deployment.
cd bc-java
chmod +x gradlew
./gradlew clean build
# to skip tests
./gradlew clean build -x testUpon a successful build, each module generates artifacts in its respective build/libs directory. Use the following command to list all binaries:
find . -name "*.jar" | grep "build/libs"Each module produces three distinct JAR types:
*.jar: The primary compiled binary required for production use.*-sources.jar: Contains the source code for IDE debugging and reference.*-javadoc.jar: Contains the API documentation.
| Module | Purpose | Artifact Path | Output JAR (v1.84) |
|---|---|---|---|
| Provider | Main JCE/JCA crypto provider | prov/build/libs/ |
bcprov-jdk18on-1.84-SNAPSHOT.jar |
| Core | Lightweight low-level crypto API | core/build/libs/ |
bccore-jdk18on-1.84-SNAPSHOT.jar |
| PKIX | Certificates (X.509), CMS, PKCS#12 | pkix/build/libs/ |
bcpkix-jdk18on-1.84-SNAPSHOT.jar |
| TLS | TLS/SSL & JSSE provider | tls/build/libs/ |
bctls-jdk18on-1.84-SNAPSHOT.jar |
| Util | ASN.1 and PKIX utility classes | util/build/libs/ |
bcutil-jdk18on-1.84-SNAPSHOT.jar |
| PG | OpenPGP implementation | pg/build/libs/ |
bcpg-jdk18on-1.84-SNAPSHOT.jar |
If utilizing pre-compiled artifacts from Maven Central, verify them against the Bouncy Castle public key using GnuPG.
# Dearmor the public key
gpg -o bc_maven_public_key.gpg --dearmor bc_maven_public_key.asc
# Verify the JAR signature
gpg --no-default-keyring --keyring ./bc_maven_public_key.gpg --verify <file_name>.jar.asc <file_name>.jarTo verify the installation on OpenJDK 25, compile and run the following Java snippet.
Save this code as VerifyDeployment.java:
import java.security.Security;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
public class VerifyDeployment {
public static void main(String[] args) {
BouncyCastleProvider bc = new BouncyCastleProvider();
Security.addProvider(bc);
System.out.println("Bouncy Castle Provider Version: " + bc.getVersionStr());
System.out.println("Registration Status: " + (Security.getProvider("BC") != null ? "Success" : "Failed"));
}
}Execute the following commands to link the provider JAR and verify the build:
export BC_JAR="./prov/build/libs/bcprov-jdk18on-1.84-SNAPSHOT.jar"
javac -cp "$BC_JAR" VerifyDeployment.java
java -cp "$BC_JAR:." VerifyDeployment