[英]Open a File with Desktop Application with Applet
somehow I want to open a file form a web application with the desktop application from client side. 我想以某种方式从客户端与桌面应用程序一起从Web应用程序中打开文件。
My boss told me to use Applet . 我的老板告诉我要使用Applet 。 I've been through all the internet could provide me, but still can't find how to do it.
我已经遍历了互联网可以提供给我的所有信息,但仍然找不到该怎么做的信息。
I've build a code program from java class to open the file directly but I can't make the applet running from JSP file. 我已经从java类构建了一个代码程序来直接打开文件,但是我无法使applet从JSP文件运行。
Here's my code : 这是我的代码:
public static void main(String[] a) {
try {
URI uri = new URI("your/local/file/path");
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
if (desktop != null)
desktop.browse(uri);
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (URISyntaxException use) {
use.printStackTrace();
}
}
If somebody ever done it before, I'll be really thankful. 如果有人曾经做过,我将非常感激。
Normally, Applets do not have access to the local file system due to security issues. 通常,由于安全问题,Applet无法访问本地文件系统。 However, there are ways to grant file system access to applets.
但是,有一些方法可以授予文件系统对applet的访问权限。 This article describes the procedure: https://www.developer.com/java/other/article.php/3303561/Creating-a-Trusted-Applet-with-Local-File-System-Access-Rights.htm .
本文介绍了该过程: https : //www.developer.com/java/other/article.php/3303561/Creating-a-Trusted-Applet-with-Local-File-System-Access-Rights.htm 。 Altough I have not tested it myself and it is rather old, the article seems promising.
虽然我自己还没有测试过,但它已经很老了,这篇文章似乎很有希望。 I hope, this helps you.
我希望这可以帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.