If you want to disable Java for all users in Safari and Firefox (from what I have seen it doesn't appear to target Chrome) you can run the following script.
Here is the pretty uncommented version:
1#!/bin/bash23ff_users=()4os_version=$(sw_vers -productVersion)56while read -r -d $''; do7 ff_users+=("$REPLY")8done < <(mdfind -name pluginreg.dat -0)910for dat_file in "${ff_users[@]}"; do11 username=$(stat -f "%Su" "${dat_file}")12 if [[ ${os_version%.*} == 10.7 ]]; then13 { rm "${dat_file}" && awk 'BEGIN{FS=OFS=":"}/JavaAppletPlugin/{count=3}count&&!--count&&($3==1||$3==5){$3--}1' > "${dat_file}"; } < "${dat_file}"14 else15 { rm "${dat_file}" && awk 'BEGIN{FS=OFS=":"}/JavaPlugin/{count=3}count&&!--count&&($3==1||$3==5){$3--}1' > "${dat_file}"; } < "${dat_file}"16 fi17 chown "${username}" "${dat_file}"18done1920for user in /Users/*; do21 if [[ -e "${user}"/Library/Preferences ]]; then22 defaults write "${user}"/Library/Preferences/com.apple.Safari WebKitJavaEnabled -bool FALSE23 defaults write "${user}"/Library/Preferences/com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaEnabled -bool FALSE24 chown "${user##*/}" "${user}"/Library/Preferences/com.apple.Safari.plist25 fi26done
And here is the nasty one for those of you who want to know what is going on:
1#!/bin/bash23ff_users=()4os_version=$(sw_vers -productVersion)56# find all users with a Firefox profile and pluginreg.dat file within it using mdfind as suggested by Christoph von Gabler-Sahm (cvgs on jamf nation)78while read -r -d $''; do9 ff_users+=("$REPLY")10done < <(mdfind -name pluginreg.dat -0)1112# here is the find version13# while read -r -d $''; do14# ff_users+=("$REPLY")15# done < <(find /Users -name pluginreg.dat -print0 2> /dev/null161718# now we are going to disable java in Firefox19# for this we are going to use awk to modify the list of pluginreg.dat files in the ff_users array20# if statement checks for 10.7 as the relevent line is named JavaAppletPlugin in 10.7 with FF 11.021# else use JavaPlugin as found in 10.62223for dat_file in "${ff_users[@]}"; do24 username=$(stat -f "%Su" "${dat_file}")25 if [[ ${os_version%.*} == 10.7 ]]; then26 { rm "${dat_file}" && awk 'BEGIN{FS=OFS=":"}/JavaAppletPlugin/{count=3}count&&!--count&&($3==1||$3==5){$3--}1' > "${dat_file}"; } < "${dat_file}"27 else28 { rm "${dat_file}" && awk 'BEGIN{FS=OFS=":"}/JavaPlugin/{count=3}count&&!--count&&($3==1||$3==5){$3--}1' > "${dat_file}"; } < "${dat_file}"29 fi30 chown "${username}" "${dat_file}"31done3233# disable Java in Firefox34# after poking around in Firefox's sqlite files I went googling and found this post by Clay Caviness35# https://plus.google.com/109088229817689076273/posts/7yH5QGJhuyN36# I didn't know enough AWK to make that happen in a bash script but after a few tries 'mute' in #awk got it right for me3738# awk 'BEGIN{FS=OFS=":"}/JavaAppletPlugin/{p=3}p&&!--p&&($3==1||$3==5){$3--}1'3940# we can edit in-place with a little trick I orginally saw here41# http://www.unix.com/shell-programming-scripting/35591-sed-awk-inplace-inline-edit.html424344# disable Java in Safari for all users4546for user in /Users/*; do47 if [[ -e "${user}"/Library/Preferences ]]; then48 defaults write "${user}"/Library/Preferences/com.apple.Safari WebKitJavaEnabled -bool FALSE49 defaults write "${user}"/Library/Preferences/com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaEnabled -bool FALSE50 chown "${user##*/}" "${user}"/Library/Preferences/com.apple.Safari.plist51 fi52done