jdk1.4中如何为小程序提供文件写权限
我在设置小程序的策略文件时遇到问题。我是第一次这样做,不知道如何在java中设置小程序的策略文件。实际上我想授予小程序在文件系统上写入的权限。为此,我必须向小程序授予文件权限,
因此我创建了一个名为 .java.policy 的文件,并将以下代码放入其中
grant codeBase "file:/C://res/applet/*" {permission java.lang. io.FilePermission "C:\res\applet\test.txt", "读、写"; };
并将其保存在 users\jindal 文件夹中,现在我将 JAVA_HOME 设置为 c:\users\jindal
但仍然发现异常
java.security.AccessControlException: 访问被拒绝 (java.io.FilePermission C:\res\applet\test. txt 写)
任何人都可以帮忙看看出了什么问题或者我应该做什么。我必须使用 jdk 1.4
I have problem in setup of policy file for applet.I am doing this first time and don't know how to set the policy file for applet in java.Actually I want to give the permission to the applet to write on the file system. for Which I will have to give file permission to the applet
So I make a file named .java.policy and and put the following code in it
grant codeBase "file:/C://res/applet/*" { permission java.io.FilePermission "C:\res\applet\test.txt", "read, write"; };
and save this in users\jindal folder now i set the JAVA_HOME as c:\users\jindal
but still I found the exception that
java.security.AccessControlException: access denied (java.io.FilePermission C:\res\applet\test.txt write)
can any body please help what is wrong or what should i do.And I have to use jdk 1.4
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要签署您的 jar 文件
另请参阅: http://java .sun.com/developer/Books/javaprogramming/JAR/sign/signing.html
You need to sign your jar file
see also : http://java.sun.com/developer/Books/javaprogramming/JAR/sign/signing.html
你可能最好在罐子上签名。对 jar 进行签名会提升小程序的权限,从而启用文件访问。
首先你需要一个证书。您可以通过以下方式创建一个临时的:
对 jar 进行签名:
You are probably better of signing the jar. Signing the jar elevates the privileges for the applet, which enables file access.
First you need a certificate. You can create a temporary one by:
Sign the jar: