java - 如何使用 HTML 中的嵌入 Java 应用程序访问本地文件系统

标签 java html java-web-start japplet

我只是不知道应该输入什么正确的代码,我已经尝试了很多方法来获得读写权限。我的主要目标是当我单击 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并在 JNLP 中添加以下代码片段文件:



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 ApplicationsDeploying With the Applet Tag获取更多信息。

关于java - 如何使用 HTML 中的嵌入 Java 应用程序访问本地文件系统,我们在Stack Overflow上找到一个类似的问题:


java - 如何自动生成变音元音表?

java - Java 如何使用 XMX 和 XMS 内存?

java - Neo4j-shell 未启动

java - 序列化 Arraylist<CustomObject>

当屏幕尺寸较小时,Javascript 将链接添加到移动菜单。不再有效。

Java Webstart 报告错误的 Bootloader 选项

java - 使用 Java Web Start (JNLP) 部署 *.war 应用程序

javascript - 带有 div 标签的 TinyMCE?

javascript - isHidden 函数要求我在应用响应式显示时单击两次

java - Mac OS X Big Sur 上 webstart 的 JDialog 全屏问题