39

I installed Oracle JRE 7 (not JDK) for MacOSX but I can't locate where the JCE jurisdiction files are placed.

I need to replace them with the unlimited strength version.

Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
Andrea Mariottini
  • 441
  • 1
  • 5
  • 6

3 Answers3

32

I've installed the Oracle JDK, and if it helps, the directory in my case was /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre/lib/security/. Your mileage may vary, in which case just run find . -name local_policy.jar and see what it turns up.

Thom
  • 2,643
  • 2
  • 30
  • 33
  • 1
    I found 2: ./Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security/local_policy.jar ./Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre/lib/security/local_policy.jar I think the firs is what I was looking for. – Andrea Mariottini Jan 07 '13 at 11:26
26

This is for the JDK, not the JRE.


I'm on a Mac, OSx Lion and I used /usr/libexec/java_home to find my java home

/usr/libexec/java_home -V
# Matching Java Virtual Machines (3):
#     1.7.0_51, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
#     1.6.0_65-b14-462, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
#     1.6.0_65-b14-462, i386:   "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
# 
# /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home

/usr/libexec/java_home
# /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home

/usr/libexec/java_home -v 1.6
# /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

/usr/libexec/java_home -v 1.7
# /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home

From here you can use this executable and find to locate these files

find $(/usr/libexec/java_home -v 1.7) -name local_policy.jar
# /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/security/local_policy.jar

find $(/usr/libexec/java_home -v 1.7) -name US_export_policy.jar
# /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/security/US_export_policy.jar

And combine that with @ngreen's answer to get the md5 of these files (if you want)

find ~/Downloads/UnlimitedJCEPolicy -name *.jar |xargs md5
# MD5 (/Users/nperry/Downloads/UnlimitedJCEPolicy/local_policy.jar) = 9dd69bcc7637d872121880c35437788d
# MD5 (/Users/nperry/Downloads/UnlimitedJCEPolicy/US_export_policy.jar) = 3bb2e88a915b3cb003ca185357a92c16

find $(/usr/libexec/java_home -v 1.7) -name local_policy.jar | xargs md5
# MD5 (/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/security/local_policy.jar) = f41ab8f64b1fa13fec7276579c420951

find $(/usr/libexec/java_home -v 1.7) -name US_export_policy.jar | xargs md5
# MD5 (/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/security/US_export_policy.jar) = d5d126ae15abecb7d6e3a28b0d57543e

And you can see I have not replaced these files yet.

Backup the original files if you want

mkdir ~/Downloads/JCEPolicy-originals-1.7/
cp $(find $(/usr/libexec/java_home -v 1.7) -name local_policy.jar)     ~/Downloads/JCEPolicy-originals-1.7/
cp $(find $(/usr/libexec/java_home -v 1.7) -name US_export_policy.jar) ~/Downloads/JCEPolicy-originals-1.7/

You can replace the files with this.

sudo cp ~/Downloads/UnlimitedJCEPolicy/local_policy.jar $(find $(/usr/libexec/java_home -v 1.7) -name local_policy.jar)
sudo cp ~/Downloads/UnlimitedJCEPolicy/US_export_policy.jar $(find $(/usr/libexec/java_home -v 1.7) -name US_export_policy.jar)

And getting the MD5s tells me if it worked

find $(/usr/libexec/java_home -v 1.7) -name local_policy.jar | xargs md5
# MD5 (/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/security/local_policy.jar) = 9dd69bcc7637d872121880c35437788d

find $(/usr/libexec/java_home -v 1.7) -name US_export_policy.jar | xargs md5
# MD5 (/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/security/US_export_policy.jar) = 3bb2e88a915b3cb003ca185357a92c16
Community
  • 1
  • 1
Nate
  • 12,963
  • 4
  • 59
  • 80
24

Your comment on Thom's answer is correct. The JRE path is /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/, and the JCE files are then under lib/security/.

I happen to have multiple JVMs installed, so I thought it was worth showing a way to check whether a particular JVM has the correct files. These are some commands you can use to determine whether a given Java installation is configured correctly:

find ~/Downloads/UnlimitedJCEPolicy -name *.jar |xargs md5
cd /Library/Java/JavaVirtualMachines/  # -OR-
cd '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/'
find . \( -name local_policy.jar -or -name US_export_policy.jar \) |xargs md5

Once you know the path to the files, you can replace them as-needed. Keep in mind that each version of Java may require different JCE libraries. You may need separate jars for 6, 7, and 8, depending on compatibility.

Community
  • 1
  • 1
ngreen
  • 1,559
  • 13
  • 22