How to install unlimited strength JCE for Java 8 in OS X?

匿名 (未验证) 提交于 2019-12-03 02:44:02

问题:

I need to install the Java Cryptography Extension for Java 8 in OS X / mac OS. It turns out the steps from the README file which came with the installer include instructions only for Unix and Windows, but not for OS X / mac OS. I tried to put the JAR files in $JAVA_HOME/lib/security, but it didn't work either. Do you know how can I install them?

回答1:

If you are mac user, put the jars extracted from jce_policy-8.zip if your java version is 8.* use below path (to put jars under it)

/Library/Java/JavaVirtualMachines/**< jdk_version_of_your_pc >**/Contents/Home/jre/lib/security 


回答2:

Java 8 Update 161

As pointed out in another answer and in Oracle's release notes for Java 8 Update 161, unlimited cryptography is enabled by default since Update 161 and you shouldn't have to do anything if using a fresh installation of this version.

Java 8 Update 151

With Java 8 Update 151, Oracle included the same JCE mechanism into Java 8 that they already provided with Java 9. To enable JCE in Java 8 Update 151 or higher, just set the property

crypto.policy=unlimited 

in $JAVA_HOME/jre/lib/security/java.security.

It's probably a good idea to remove the old policy JAR's if they were added earlier, as Oracle states in the release notes:

Because the old JCE jurisdiction files are left in /lib/security, they may not meet the latest security JAR signing standards, which were refreshed in 6u131, 7u121, 8u111, and later updates.

Older Versions

Answers suggesting to install the JCE files via Homebrew won't work anymore, as the casks were deleted from the Homebrew repository after release of the Java 8 Update 151. If using an older version of Java 8, you can refer to the accepted answer.



回答3:

For a Mac user (OS X) on Java 8:

$ brew reinstall java8

As of JDK 1.8u151 it is not necessary to download the JCE libraries separately. Simply edit

$JDK_HOME/jre/lib/security/java.security

and uncomment the line:

crypto.policy=unlimited

This will enable the unlimited strength JCE.

JDK 1.8u151 Release Notes



回答4:

As of Java 8u152, unlimited strength can be enabled simply by setting crypto.policy=unlimited in the java.security file in

/Library/Java/JavaVirtualMachines/<jdk_version>/Contents/Home/jre/lib/security  

It's already in that file but commented out.

See http://www.oracle.com/technetwork/java/javase/8u152-relnotes-3850503.html#JDK-8157561



回答5:

As you did not explain what is your problem here some guesses.

  1. Using an internet search engine you probably would have found this page http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
  2. you might have downloaded this file jce_policy-8.zip
  3. maybe you would have unzipped it and had a look into directory UnlimitedJCEPolicyJDK8/
  4. maybe the file README.txt would have attracted your interest

If all of those steps would have been true, then you would have found

3)  Install the unlimited strength policy JAR files.  In case you later decide to revert to the original "strong" but limited policy versions, first make a copy of the original JCE policy files (US_export_policy.jar and local_policy.jar). Then replace the strong policy files with the unlimited strength versions extracted in the previous step.  The standard place for JCE jurisdiction policy JAR files is:      <java-home>/lib/security           [Unix]     <java-home>\lib\security           [Windows] 

You can assume that the location on OSX is the same as for the listed systems.



回答6:

For later versions of macOS (e.g., Sierra), Oracle Java is installed in two locations depending on if you install the JRE or JDK.

  • JRE: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/
  • JDK: /Library/Java/JavaVirtualMachines/jdk1.x.x_xxx.jdk/Contents/Home/
    • If you install the JDK, it will also install the JRE at the JRE location listed above.

The JRE allows you to double-click to open jars from the Finder and run Java in the browser. The JRE does not come with the java binary, so if you want to run any of the typical Java commands, you must install the JDK. More at https://java.com/en/download/faq/yosemite_java.xml.

All this to say, when installing then unlimited strength JCE files, install them in both directories listed above to get consistent behavior.



回答7:

As of Java JDK version 8u161 unlimited cryptography is enabled by default and the other suggested methods should no longer be necessary (unless you want to disable it).

This change also appears to be included in other major JDK versions from JDK 6 to JDK 9.



回答8:

if you're a windows user:

download the most updated JCE on http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

extract zip file and copy the two jar files in the following directory

\Program Files\Java\jre1.8.0_131\lib\security



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