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

3

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?

Zamindar answered 25/10, 2012 at 18:2 Comment(1)
Use the JNLP API to copy or other methods to copy. See this applet 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+ for more details on the implementation.Mayberry
A
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"
Archibaldo answered 4/1, 2013 at 21:49 Comment(3)
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.Zamindar
This is th only reference I found so far:esecurityplanet.com/patches/article.php/3925146/…Archibaldo
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,467Archibaldo
M
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)
Matta answered 18/4, 2013 at 17:30 Comment(2)
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?Underarm
Thank you for your hint. I just saw it and have added a summary to my original post above.Matta
Z
0

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

Zamindar answered 5/11, 2012 at 13:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.