Monday, 14 July 2014

java.security.NoSuchProviderException

This exception is thrown when a particular security provider is requested but is not available in the environment.

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

public class KeyGeneratorGetInstance1 {
    public static void main(String args[])throws NoSuchAlgorithmException, NoSuchProviderException{
        KeyGenerator keyGen = KeyGenerator.getInstance("AES", "ptr");
    }
}

When you tries to run the above program, below error thrown.

Exception in thread "main" java.security.NoSuchProviderException: no such provider: ptr
 at sun.security.jca.GetInstance.getService(GetInstance.java:83)
 at javax.crypto.JceSecurity.getInstance(JceSecurity.java:97)
 at javax.crypto.KeyGenerator.getInstance(KeyGenerator.java:250)
 at KeyGeneratorGetInstance1.main(KeyGeneratorGetInstance1.java:6)
Java Result: 1

                                                             Home

No comments:

Post a Comment