Java Error: please install JCE Unlimited Strength Jurisdiction Policy files

别来无恙 提交于 2019-12-24 01:12:57

问题


I am working on this Java application which needs to have access to "JCE Unlimited Strength" files and I DO HAVE installed them and it works properly when I build the solution (in Intellij) BUT when I make a jar output, for some reason it gives me this annoying error:

C:\Users\h\whatever\out\artifacts\Accepter_jar>java -cp Accepter.jar Main
org.apache.poi.EncryptedDocumentException: Export Restrictions in place - please install JCE Unlimited Strength Jurisdic
tion Policy files
        at org.apache.poi.poifs.crypt.CryptoFunctions.getCipher(CryptoFunctions.java:208)
        at org.apache.poi.poifs.crypt.CryptoFunctions.getCipher(CryptoFunctions.java:182)
        at org.apache.poi.poifs.crypt.agile.AgileDecryptor.hashInput(AgileDecryptor.java:269)
        at org.apache.poi.poifs.crypt.agile.AgileDecryptor.verifyPassword(AgileDecryptor.java:116)
        at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:95)
        at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:282)
        at ExcelJob.loadExcelSheet(ExcelJob.java:22)
        at Main.main(Main.java:17)

any idea what is the problem?


回答1:


I have gone through similar issue but with eclipse instead Intellij. It could be the problem with the jdk(multiple versions) and jre. Go to your C:\Program Files\Java directory, add the NEWLY DOWNLOADED JCE jars (depending upon the Java version) inside security folder of each of JDK & JRE you have installed.




回答2:


On Windows installing the unlimited strength policy files is an annoying task, especially as after every JDK/JRE update you have to do it again.

Therefore I created a Windows batch file that automates the installation for all installed 64 bit Java 8 JREs and JDKs:

@Echo Off
FOR /D %%G in ("%ProgramFiles%\Java\jdk*.*") DO (Echo Upgrading JDK %%G & "C:\Program Files\7-Zip\7z.exe" e -ir!*.jar -aoa -o"%%G\jre\lib\security" "%~dp0jce_policy-8.zip" > NUL:)
FOR /D %%G in ("%ProgramFiles%\Java\jre*.*") DO (Echo Upgrading JRE %%G & "C:\Program Files\7-Zip\7z.exe" e -ir!*.jar -aoa -o"%%G\lib\security" "%~dp0jce_policy-8.zip" > NUL:)
pause
  1. Downloaded from Oracle the file jce_policy-8.zip.
  2. Save the script text from above into a text file, e.g. name it jce_policy-8_install.cmd. Place it into the same directory as jce_policy-8.zip.
  3. Now right click the jce_policy-8_install.cmd file in the Windows Explorer and select "Run as administrator".

Note the script requires 7zip 64 bit installed into the default path (C:\Program Files\7-Zip).




回答3:


While running nebeans you will come to know JAVA_HOME path while doing clean and build program ,that time you will come to know where is the java path

IF you are using linux http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html download this jar file and extract it first ,you will find local_policy and US_export.jar file you need to copy those two files into your /usr/local/jdk1.8.0_151/jre/lib/security/ copy it here it will ask to overrite say yes. And then re run your netbeans



来源:https://stackoverflow.com/questions/37888701/java-error-please-install-jce-unlimited-strength-jurisdiction-policy-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!