简体   繁体   English

使用Applet使用桌面应用程序打开文件

[英]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.

相关问题 将文件从桌面上传到Java Applet应用程序 - Upload file from desktop to Java applet application Java:将小程序转换为桌面应用程序 - Java: Convert an applet to a desktop application 将Java Applet嵌入C#桌面应用程序 - embed java applet into C# desktop application 双击将netbeans项目的war文件转换为桌面应用程序 - Convert war file of netbeans project to desktop application open on double click 使用Java Desktop.open(文件f)并知道应用程序已完成 - using Java Desktop.open( FIle f ) and knowing that the application is done Java:如何从本地Java桌面应用程序与Java Applet通信? - Java : how to communicate from localhost Java desktop application to Java Applet? Java Applet打开,编辑和保存图像文件 - Java Applet open, edit and save image file 对于Windows 7或XP上已签名的Java Applet,什么会导致Desktop.isDesktopSupported()= true,但是导致desktop.isSupported(Desktop.Action.OPEN)= false? - For a signed java applet on Windows 7 or XP, what would cause Desktop.isDesktopSupported()=true but desktop.isSupported(Desktop.Action.OPEN)=false? Libgdx教程:无法打开桌面应用程序 - Libgdx tutorial: cannot open desktop application 如何从 Angular 应用程序打开桌面应用程序? - How to open a desktop app from Angular application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM