Home > Bash scripting, Java, Mac administration, Mac OS X > Re-enable the Apple Java 6 plug-in for use with web browsers

Re-enable the Apple Java 6 plug-in for use with web browsers

Once the Java for OS X 2012-006 update has been installed, the Apple-provided Java applet plug-in from /Library/Internet Plug-Ins is removed, which means that web browsers will not be able to launch Java applets from inside the browser. The update also removes the Java Preferences application from /Applications/Utilities.

However, the rest of the Java 6 framework is still installed and it is possible to re-enable the Apple-provided Java plug-in and browser functionality. Apple has provided a KBase article showing how to do this process manually, which allowed me to build a script that automates the process of removing the Oracle Java 7 plug-in and replace it with the Apple-built Java 6 plug-in.


#!/bin/sh

# Checks for backup directory for Java 7 plug-in
# and creates it if needed.

if [ -d "/Library/Internet Plug-Ins (Disabled)" ]; then
     echo "Backup Directory Found"
  else
     mkdir "/Library/Internet Plug-Ins (Disabled)"
     chown -R root:wheel "/Library/Internet Plug-Ins (Disabled)"
fi

# If a previous version of the Java 7 plug-in is already 
# in the backup directory, the previously backed up Java 7 
# plug-in is removed.

if [ -d "/Library/Internet Plug-Ins (Disabled)/JavaAppletPlugin.plugin" ]; then
      rm -rf "/Library/Internet Plug-Ins (Disabled)/JavaAppletPlugin.plugin"
fi

# Moves current Java 7 plug-in to the backup directory

if [ -d "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" ]; then
     mv "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" "/Library/Internet Plug-Ins (Disabled)/JavaAppletPlugin.plugin"
fi

# Create symlink to the Apple Java 6 plug-in in
# /Library/Internet Plug-Ins 

ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin"

# Re-enable Java SE 6 Web Start, which allows Java 
# applets to run in web browsers

ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws

exit 0

This script is available here on my GitHub repo.

Update – 11-4-2012: I’ve received some emails asking for assistance with running this script. To help make this process easier, I’ve built and posted a payload-free installer package to my GitHub repo. If you need it, download the installer package and run it to execute the script on your own Mac.

  1. October 25, 2012 at 5:20 am

    Thanks for sharing … I am SURE that some colleagues will come to me in next months asking me why “java is broken” on their biotech software webapp.

    Then I will use your tip!

  2. Hugh
    November 1, 2012 at 11:37 pm

    what is -d ?
    -d “/Library/Internet Plug-Ins (Disabled)”
    -bash: -d: command not found

  3. Rick Freeborn
    November 13, 2012 at 2:22 pm

    I have been testing with using the enable Java Web Plugins Script you posted on Github and seems to be working for me but I need additional entries in script to also switch to 32 bit preferred on 1100 MacBooks for an upcoming ACT Survey that does not support Java in 64 bit mode. Any help would be greatly appreciated.

    • November 13, 2012 at 5:19 pm

      Rick,

      Unfortunately, getting 32-bit Java working once the Java for OS X 2012-006 update has been installed is beyond the scope of my script. The best advice I can offer in this case is to not install Java for OS X 2012-006.

  4. Nick Kutzko
    November 16, 2012 at 2:57 pm

    I am having some problems with this script as well as the package. When I run the script or the installer it says it finished but the Power School grade book app still will not launch and tells me I need to install the Java runtime, providing a link to Oracle. Any idea what’s stopping me?

    Thanks!

    • November 16, 2012 at 3:29 pm

      Nick,

      Check with Pearson, I believe they put out an update for PowerSchool that fixes this issue:

      https://discussions.apple.com/thread/4458993

      • Nick Kutzko
        November 16, 2012 at 3:31 pm

        Unfortunately, we just did the PS update before I installed the Java update that requires this fix.

      • Nick Kutzko
        November 16, 2012 at 4:32 pm

        Also, I would like to add that this only seems to be happening on our new iMacs. My 2012 MacBook Pro has no trouble at all, running Java 6. I am fully up to date, as well.

  5. Jonathan Moss
    November 28, 2012 at 6:24 pm

    How do I undo this script? In essence, I ran it before realizing java had never been installed and want to start over.

  6. December 30, 2012 at 12:32 pm

    good tutorial.. thanks for sharing.. :)

  7. Flip
    February 8, 2013 at 9:47 pm

    To the original poster, THANK YOU! was pulling my hair to get Java 6 enabled in all of my browsers and this did the trick. :)

  8. raidem8
    February 14, 2013 at 9:54 pm

    This was a life saver, thank you so much for sharing.

  9. toddy
    August 22, 2013 at 9:15 pm

    I can’t believe how easily this solved my problem with this. Thank you very much for your help.

  10. David Diaz
    February 18, 2014 at 10:30 pm

    Totally worked, thanks so much for sharing the script

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 154 other followers

%d bloggers like this: