You are not logged in.

#1 2011-10-06 14:36:54

pokraka
Member
From: Brussels
Registered: 2009-01-15
Posts: 63

Using Bouncy Castles in Java

Hi,

Basically I just need to compile this code :

import java.security.*;
import javax.crypto.*;

public class BlockCipherEngine {
    public static void main(String[] args) {
        Security.addProvider( new org.bouncycastle.jce.provider.BouncyCastleProvider() );
        Cipher cipher = Cipher.getInstance("AES", "BC");
    }
}

But I get the following :

package org.bouncycastle.jce.provider does not exist

I installed bcprov and added /usr/share/bcprov.jar to my $CLASSPATH.
What should I do ?

Thanks.

Offline

#2 2011-10-06 14:52:08

sunckell
Member
Registered: 2009-11-16
Posts: 6

Re: Using Bouncy Castles in Java

bcprov installs to /usr/share/java/bcprov.jar  not /usr/shar/bcprov.jar

adjust your CLASSPATH and try again?

Offline

#3 2026-05-15 18:38:15

prittspadelord
Member
Registered: 2026-05-15
Posts: 1

Re: Using Bouncy Castles in Java

Are you using Maven? If so, that class `org.bouncycastle.jce.provider.BouncyCastleProvider` is actually found in `bcprov-lts8on`, which you can add using:

<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcprov-lts8on</artifactId>
    <version>2.73.11</version>
</dependency>

If you ever find yourself not knowing which dependency a particular class came from in the future, you can use https://central.sonatype.com/ and search `fc:fully.qualified.name.of.Clazz` to identify dependencies that provide it. You can filter it even further if you know the group id, as I did in your case, using `g:org.bouncycastle fc:org.bouncycastle.jce.provider.BouncyCastleProvider`. There are a ton of results, but `bcprov-lts8on` is the one you want as it's the LTS version aimed for Java 8 and higher.

Last edited by prittspadelord (2026-05-15 18:38:42)

Offline

#4 2026-05-15 20:36:07

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,987

Re: Using Bouncy Castles in Java

You did realise this thread is 15 years old ?
Please read https://wiki.archlinux.org/title/Genera … bumping%22

Moderator Note
Closing this old thread.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

Board footer

Powered by FluxBB