我如何使用 HTML 中的嵌入 Java 应用程序访问本地文件系统
How can i have local file system access using embed Java application in HTML
我只是不知道我应该输入什么正确的代码,我已经尝试了很多方法来获得读写权限。我的主要目标是当我单击 Java 应用程序中的按钮时,下载将开始。
您无法从 Java 沙盒小程序访问本地文件系统。阅读文档What Applets Can and Cannot Do,您将看到:
Sandbox applets cannot perform the following operations:
They cannot access client resources such as the local filesystem, executable files, system clipboard, and printers.
They cannot connect to or retrieve resources from any third party server (any server other than the server it originated from).
They cannot load native libraries.
They cannot change the SecurityManager.
They cannot create a ClassLoader.
They cannot read certain system properties. See System Properties for a list of forbidden system properties.
如果您想绕过这些限制,您必须使用特权小程序:
Privileged applets do not have the security restrictions that are imposed on sandbox applets and can run outside the security sandbox.
为此,您需要 sign your jar and add the following code snippet in the JNLP 文件:
<security>
<all-permissions/>
</security>
然后用户必须授予权限。来自文档:
The first time an RIA is launched, the user is prompted for permission to run. The dialog shown provides information about the signer's certificate and indicates if the RIA requests permission to run outside the sandbox. The user can then make an informed decision about running the application.
阅读 Security in Rich Internet Applications and Deploying With the Applet Tag 了解更多信息。
我只是不知道我应该输入什么正确的代码,我已经尝试了很多方法来获得读写权限。我的主要目标是当我单击 Java 应用程序中的按钮时,下载将开始。
您无法从 Java 沙盒小程序访问本地文件系统。阅读文档What Applets Can and Cannot Do,您将看到:
Sandbox applets cannot perform the following operations:
They cannot access client resources such as the local filesystem, executable files, system clipboard, and printers.
They cannot connect to or retrieve resources from any third party server (any server other than the server it originated from).
They cannot load native libraries.
They cannot change the SecurityManager.
They cannot create a ClassLoader.
They cannot read certain system properties. See System Properties for a list of forbidden system properties.
如果您想绕过这些限制,您必须使用特权小程序:
Privileged applets do not have the security restrictions that are imposed on sandbox applets and can run outside the security sandbox.
为此,您需要 sign your jar and add the following code snippet in the JNLP 文件:
<security>
<all-permissions/>
</security>
然后用户必须授予权限。来自文档:
The first time an RIA is launched, the user is prompted for permission to run. The dialog shown provides information about the signer's certificate and indicates if the RIA requests permission to run outside the sandbox. The user can then make an informed decision about running the application.
阅读 Security in Rich Internet Applications and Deploying With the Applet Tag 了解更多信息。