2

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
  • 3,689
  • 4
  • 32
  • 45
  • Use the JNLP API to copy or other methods to copy. See [this applet](http://pscode.org/prop/?prop=java.version&format=TSV) for an example. If it works on the problem machines, it might be workable for this use-case. See [Copy in sand-boxed app. in 1.6.0_24+](https://forums.oracle.com/forums/message.jspa?messageID=9469923) for more details on the implementation. – Andrew Thompson Oct 26 '12 at 07:44

3 Answers3

3

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"
Guido
  • 926
  • 2
  • 10
  • 19
  • 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. – Joshua Smith Jan 05 '13 at 15:50
  • This is th only reference I found so far:http://www.esecurityplanet.com/patches/article.php/3925146/Oracle-Updates-Java-for-21-Vulnerabilities.htm – Guido Jan 05 '13 at 16:18
  • A discussion about how the work-around solution worked for different people on different platforms can be seen here: http://www.sqlinform.com/forum4/read.php?3,467 – Guido Jan 05 '13 at 16:19
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)
  • Welcome to SO! Following the guidelines of "how to write a good answer" (http://meta.stackexchange.com/questions/7656/how-do-i-write-a-good-answer-to-a-question), 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? – Peter Mularien Apr 18 '13 at 17:50
  • Thank you for your hint. I just saw it and have added a summary to my original post above. – Alexander Klar Oct 20 '17 at 12:51
0

Until they fix the bug, I've found that signing the applet allows copy/paste to work.

Joshua Smith
  • 3,689
  • 4
  • 32
  • 45