简体   繁体   English

Java 小程序:从浏览器运行本机代码?

[英]Java applet: run native code from browser?

Is it still possible to start a 'native' application under windows via a java applet in a browser?是否仍然可以通过浏览器中的 java 小程序在 windows 下启动“本机”应用程序? IE "Click here to start notepad.exe" on a web page. web 页面上的 IE “单击此处启动 notepad.exe”。 The most recent reference I could find for this was dated 2002. Im wondering if this model / concept is no longer supported.我能找到的最新参考是 2002 年。我想知道这个 model / 概念是否不再受支持。

Yes, but the applet has to be signed.可以,但是必须对小程序进行签名。

Signed applets will prompt the user to give them permission. 签名的小程序将提示用户授予他们权限。 Once given, the applet has the same rights as any application running on the machine, including the ability to launch native apps (or link native libraries, which I've had to do in the past).一旦给定,小程序就拥有与机器上运行的任何应用程序相同的权利,包括启动本机应用程序(或链接本机库,我过去必须这样做)的能力。

..Is it still possible to start a 'native' application under windows via a java applet in a browser? ..是否仍然可以通过浏览器中的 java 小程序在 windows 下启动“本机”应用程序?

Sure thing.肯定的事。 As mentioned in other replies, a signed (and trusted) applet can use Runtime.exec(String) to launch a native application.正如其他回复中提到的,签名(且受信任)的小程序可以使用Runtime.exec(String)来启动本机应用程序。

As of Java 1.6, it becomes simpler with the implementation of Dekstop.getDesktop.open(File) , which will open the selected File with whatever application the OS has registered as a consumer for that file type.从 Java 1.6 开始,通过实施Dekstop.getDesktop.open(File)变得更加简单,它将使用操作系统注册为该文件类型的使用者的任何应用程序打开选定的File

As of Sun's Plugin2 architecture (1.6.0_10+ in a Sun/Oracle JRE) offers a more generic method for an (sand-boxed) applet embedded in a web page, using the JNLP API's BasicService .从 Sun 的 Plugin2 架构(Sun/Oracle JRE 中的 1.6.0_10+)开始,使用 JNLP API 的BasicService为嵌入在 web 页面中的(沙盒)小程序提供了更通用的方法。 Here is my demo.这是我的演示。 of the BasicService BasicService

The portable way of doing this is to create a signed Applet .这样做的可移植方式是创建一个签名的 Applet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM