Any workaround to getting Copy/Paste working in JDK 7 AWT Applet on Mac?

12,015

Solution 1

Oracle released Java 6 Update 24 in February 2011 to remedy 21 vulnerabilities: Announcement

As part of this security release, the ability to copy & paste from a computer's clipboard into a Java applet has been disabled.

To fix this issue there are 2 solutions:

  1. Create a digital signature for the applet.
  2. Work around: If you do not want to work with the digital signature, add to your java.policy file the following line: permission java.awt.AWTPermission "accessClipboard"

Solution 2

Here is a great and very detailed walk-through to do it the official Java way using their policy tool:

http://www.shodor.org/interactivate/resources/InstructionsCopyPaste/

Here is a quick summary of the instructions:

  1. in Terminal.app type "policytool" and hit [Enter]
  2. dismiss any error message and choose "Save" from the "File" menu
  3. save as ".java.policy" (with a preceding dot) in your user's home directory
  4. click "Add Policy Entry" and then "Add Permission"
  5. choose "AWTPermission" as the permission and "accessClipboard" as the target
  6. click "OK", then "Done"
  7. choose "Save" again, then "Exit" from the "File" menu
  8. restart your browser (or your computer if copy/paste still doesn't work)
Share:
12,015
Joshua Smith
Author by

Joshua Smith

Updated on June 04, 2022

Comments

  • Joshua Smith
    Joshua Smith almost 2 years

    Since Apple forced the update to JDK 7 on Mac, old AWT applets no longer support copy/paste. For example, if you visit:

    Simple AWT Textfield Example

    you cannot copy and paste into the applet text field on that page. I've confirmed that you can still copy/paste in AWT on Windows with JDK 7.

    Anybody know a workaround?

  • Joshua Smith
    Joshua Smith over 11 years
    This is consistent with my findings. Can you provide a reference for this? I cannot find this documented in any of the release notes, and the Java teams at Oracle and Apple were not aware of this being "as designed" behavior. They encouraged me to file a bug report.
  • Guido
    Guido over 11 years
    This is th only reference I found so far:esecurityplanet.com/patches/article.php/3925146/…
  • Guido
    Guido over 11 years
    A discussion about how the work-around solution worked for different people on different platforms can be seen here: sqlinform.com/forum4/read.php?3,467
  • Peter Mularien
    Peter Mularien about 11 years
    Welcome to SO! Following the guidelines of "how to write a good answer" (meta.stackexchange.com/questions/7656/…), could you please try to summarize the instructions from the linked site so that future SO readers may benefit even if the site goes away?
  • Alexander Klar
    Alexander Klar over 6 years
    Thank you for your hint. I just saw it and have added a summary to my original post above.