复制/粘贴在已签名的 Applet 中不起作用 [英] Copy/Paste not working in a signed Applet

查看:22
本文介绍了复制/粘贴在已签名的 Applet 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 signed 小程序(它通过 jarsigner 验证正确)由于某种原因不允许从系统剪贴板复制和粘贴到 JTextField 尽管文档告诉我它应该适用于签名的小程序.

I've a signed applet (which verifies correctly with jarsigner) that for some reason will not allow copy and paste from the system clipboard into a JTextField despite the documentation telling me that it is supposed to work for signed applets.

此外,我还有其他使用相同密钥文件签名的小程序,可以让我复制和粘贴文本.我在互联网上搜索了高低,似乎找不到任何线索.令我费解的是似乎没有办法调试它(控制台中没有输出 - 没有抛出异常).

Furthermore, I've other applets which are signed with the same keyfile that do let me copy and paste text. I have searched high and low on the internet and can't seem to find any clues. What is making me pull my hair out is that there seems to be no way to debug this (no output in the console - no thrown exceptions).

有人对我如何调试它以找出 Java 不喜欢这个特定小程序的原因有任何想法吗?

Does any one have any ideas on how I can debug this to find out why Java doesn't like this particular applet?

非常感谢您的任何建议!

Many thanks for any suggestions!

推荐答案

好吧,事实证明随着 2011 年 2 月 Java Plug-in 1.6.0_24 的发布,从系统剪贴板复制和粘贴被认为是一个安全漏洞和残疾.您可以在小程序之间复制和粘贴.但是,如果您尝试使用主剪贴板中的某些内容,则无法将其复制进去.

Well, it turns out with the release of the Java Plug-in 1.6.0_24 in February 2011, copy and paste from the system clipboard was deemed a security hole and disabled. You can copy and paste BETWEEN applets. But if you try to use something from your main clipboard, it can't be copied in.

因此有几种解决方法.您可以回滚到插件的早期版本.这会起作用,但很有可能所有未来的版本仍会禁用复制和粘贴,因此您永远无法升级.

So there are a couple of options for a workaround. You can roll back to an earlier version of the plug-in. That will work, but chances are all future releases will still keep copy and paste disabled, so you'd never be able to upgrade.

另一种选择是提供一个自定义的 java 安全策略文件,它允许再次访问系统剪贴板.

The other alternative is to provide a custom java security policy file which enables access to the system clipboard again.

首先找到您本地的 Java 安全策略文件.该文件名为 java.policy,应位于 Java 安装的 lib\security 文件夹中.在 Windows 7 上,它可以在 C:\Program Files (x86)\Java\jre6\lib\security 中找到.将此文件复制到您的主文件夹(例如 C:\Users\Kyle).将文件重命名为 .java.policy(注意开头的句点).在文本编辑器中编辑文件.找到这行文本:

First locate your local Java Security Policy file. The file is named java.policy and should be in the lib\security folder of your Java installation. On Windows 7, it can be found at C:\Program Files (x86)\Java\jre6\lib\security. Copy this file to your home folder (ex. C:\Users\Kyle). Rename the file to .java.policy (note the period at the beginning). Edit the file in a text editor. Locate this line of text:

// "standard" properies that can be read by anyone

在其下方添加以下行,如下所示:

Add the following line just below it like so:

// "standard" properies that can be read by anyone
permission java.awt.AWTPermission "accessClipboard";

保存文件.在测试之前关闭所有打开的浏览器并确保 Java 没有运行.

Save the file. Close any open browsers and ensure that Java is not running before testing.

来源:http://blogs.oracle.com/kyle/entry/copy_and_paste_in_java

这篇关于复制/粘贴在已签名的 Applet 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆