Jak*_*mpl 5 html javascript flash silverlight
如果我有一个文件系统路径可我打开资源管理器窗口(Windows上)或查找器(在OS X)显示的路径通向文件夹?
Cookie指向跨平台和/或无插件的答案.
您需要能够从浏览器运行新进程。有几种方法可以做到这一点。我将展示 JNLP 的方法来做到这一点。
创建jnlp文件如下:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://example/" href="jnlpTest.jnlp">
<information>
<title>Some Title</title>
<vendor>Some Vendor</vendor>
<homepage href="http://example/" />
<description>Some Description</description>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+" />
<jar href="jnlpTest.jar" />
</resources>
<application-desc main-class="MainClass" />
</jnlp>
Run Code Online (Sandbox Code Playgroud)
从以下内容创建 jnlpTest.jar:
public class MainClass {
public static void main(String args[]) {
Runtime rt = Runtime.getRuntime();
try {
//TODO - different exec for Mac
rt.exec("explorer.exe");
} catch (IOException e) {
//exception
}
}
}
Run Code Online (Sandbox Code Playgroud)
带有清单:
Manifest-Version: 1.0
Main-Class: MainClass
Run Code Online (Sandbox Code Playgroud)
签署您的 JNLP jar:
keytool -genkey -keystore testKeys -alias jdc
jarsigner -keystore testKeys jnlpTest.jar jdc
Run Code Online (Sandbox Code Playgroud)
将 jar 和 jnlp 文件放在 Web 服务器上。确保 mime 类型 JNLP 被用作application/x-java-jnlp-file.
制作JNLP的参考:http://java.dzone.com/articles/java-web-start-jnlp-hello
现在,当用户单击您的 jnlp 链接时,他们将下载该 jar 并被询问是否可以运行。运行它将导致资源管理器窗口打开。我知道这不是最好的解决方案,但任何解决方案都需要询问用户在其计算机上执行代码的权限。