如何在 OS X 中为 Java 8 安装无限强度 JCE?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37741142/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install unlimited strength JCE for Java 8 in OS X?
提问by JonDoe297
I need to install the Java Cryptography Extensionfor Java 8
in OS X
/ mac OS
. It turns out the steps from the READMEfile which came with the installerinclude 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?
我需要为in /安装Java Cryptography Extension。事实证明,安装程序随附的 README文件中的步骤仅包含针对和的说明,但不包含针对/ 的说明。我试图将 JAR 文件放入. 你知道我该如何安装它们吗?Java 8
OS X
mac OS
Unix
Windows
OS X
mac OS
$JAVA_HOME/lib/security
采纳答案by anothernode
Java 8 Update 161
Java 8 更新 161
As pointed out in another answerand 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 or higher.
正如另一个答案和 Oracle 的Java 8 Update 161 发行说明中所指出的,自 Update 161 以来,默认情况下启用了无限制加密,如果使用此版本或更高版本的全新安装,您无需执行任何操作。
Java 8 Update 151
Java 8 更新 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
在 Java 8 Update 151 中,Oracle 在 Java 8 中包含了与 Java 9 相同的 JCE 机制。要在 Java 8 Update 151 或更高版本中启用 JCE,只需设置属性
crypto.policy=unlimited
in $JAVA_HOME/jre/lib/security/java.security
.
在$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:
正如 Oracle 在发行说明中所述,如果较早添加旧策略 JAR,则删除它们可能是一个好主意:
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.
由于旧的 JCE 权限文件留在 /lib/security 中,它们可能不符合最新的安全 JAR 签名标准,这些标准在 6u131、7u121、8u111 和以后的更新中被刷新。
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'll have to put the JCE-Policy-JAR manually as described in another answer.
建议通过 Homebrew 安装 JCE 文件的答案将不再有效,因为在 Java 8 Update 151 发布后,木桶已从 Homebrew 存储库中删除。如果使用旧版本的 Java 8,则必须放置 JCE -Policy-JAR 手动,如另一个答案中所述。
回答by SubOptimal
As you did not explain what is your problem here some guesses.
由于您没有在这里解释您的问题是什么,所以有些猜测。
- Using an internet search engine you probably would have found this page http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
- you might have downloaded this file
jce_policy-8.zip
- maybe you would have unzipped it and had a look into directory
UnlimitedJCEPolicyJDK8/
- maybe the file
README.txt
would have attracted your interest
- 使用 Internet 搜索引擎,您可能会找到此页面http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
- 你可能已经下载了这个文件
jce_policy-8.zip
- 也许你会解压它并查看目录
UnlimitedJCEPolicyJDK8/
- 也许该文件
README.txt
会引起您的兴趣
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.
您可以假设 OSX 上的位置与所列系统的位置相同。
回答by praxnet
Note: As of Java JDK version 8u161 unlimited cryptography is enabled by default
注意:自 Java JDK 版本 8u161 起,默认启用无限制加密
FOR MacOS user
对于 MacOS 用户
If you are MacOS user, put the jars extracted from jce_policy-8.zipif your java version is 8.* use below path (to put jars under it)
如果你是 MacOS 用户,如果你的 java 版本是 8.*把从jce_policy-8.zip 中提取的 jars 放在下面的路径中(把 jars 放在它下面)
/Library/Java/JavaVirtualMachines/**< jdk_version_of_your_pc >**/Contents/Home/jre/lib/security
回答by yanokwa
For later versions of macOS (e.g., Sierra), Oracle Java is installed in two locations depending on if you install the JRE or JDK.
对于更高版本的 macOS(例如 Sierra),Oracle Java 安装在两个位置,具体取决于您安装的是 JRE 还是 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.
- JRE:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/
- JDK:
/Library/Java/JavaVirtualMachines/jdk1.x.x_xxx.jdk/Contents/Home/
- 如果您安装 JDK,它还会在上面列出的 JRE 位置安装 JRE。
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.
JRE 允许您双击以从 Finder 中打开 jar 并在浏览器中运行 Java。JRE 不附带java
二进制文件,因此如果要运行任何典型的 Java 命令,则必须安装 JDK。更多信息请访问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.
这就是说,在安装无限强度 JCE 文件时,将它们安装在上面列出的两个目录中以获得一致的行为。
回答by Boris_Ndong
if you're a windows user:
如果您是 Windows 用户:
download the most updated JCE on http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
在http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html上下载最新的 JCE
extract zip file and copy the two jar files in the following directory
解压zip文件并将两个jar文件复制到以下目录
\Program Files\Java\jre1.8.0_131\lib\security
\Program Files\Java\jre1.8.0_131\lib\security
回答by Fredric Doddridge
For a Mac user (OS X) on Java 8:
对于使用 Java 8 的 Mac 用户 (OS X):
$ brew reinstall java8
$ brew 重新安装java8
As of JDK 1.8u151 it is not necessary to download the JCE libraries separately. Simply edit
从 JDK 1.8u151 开始,不需要单独下载 JCE 库。只需编辑
$JDK_HOME/jre/lib/security/java.security
$JDK_HOME/jre/lib/security/java.security
and uncomment the line:
并取消注释该行:
crypto.policy=unlimited
crypto.policy=unlimited
This will enable the unlimited strength JCE.
这将启用无限强度的 JCE。
回答by Alanyst
As of Java 8u152, unlimited strength can be enabled simply by setting crypto.policy=unlimited
in the java.security
file in
从 Java 8u152 开始,只需crypto.policy=unlimited
在java.security
文件中设置即可启用无限强度
/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
见http://www.oracle.com/technetwork/java/javase/8u152-relnotes-3850503.html#JDK-8157561
回答by robSE13
As of Java JDK version 8u161 unlimited cryptography is enabled by defaultand the other suggested methods should no longer be necessary (unless you want to disable it).
从 Java JDK 版本 8u161 开始,默认启用无限制加密,并且不再需要其他建议的方法(除非您想禁用它)。
This change also appears to be included in other major JDK versions from JDK 6 to JDK 9.