InvalidKeyException : Illegal Key Size – Java code throwing exception for encryption class – how to fix?

So the problem must be with your JCE Unlimited Strength installation.

Be sure you overwrite the local_policy.jar and US_export_policy.jar in both your JDK’s jdk1.6.0_25\jre\lib\security\ and in your JRE’s lib\security\ folder.

In my case I would place the new .jars in:

C:\Program Files\Java\jdk1.6.0_25\jre\lib\security

and

C:\Program Files\Java\jre6\lib\security


If you are running Java 8 and you encounter this issue. Below steps should help!

Go to your JRE installation (e.g – jre1.8.0_181\lib\security\policy\unlimited) copy local_policy.jar and replace it with ‘local_policy.jar’ in your JDK installation directory (e.g – jdk1.8.0_141\jre\lib\security).

Leave a Comment