Search code examples
javajavascriptsecurityappletnext-generation-plugin

Can a Java applet open a "select directory" and write to a filesystem via JavaScript interaction?


I am looking for a way to save a couple of files created with JavaScript on the clients computer. I want him to be able to choose a folder (similar to open/save folder dialog), and then write the files there. This obviously requires three things:

  • Ability to popup such a dialog.
  • Ability to write on the client's computer (signed applets?)
  • Some way to interact with JavaScript because it knows the filenames and contents to write.

Is this possible or should I just stop dreaming?


Solution

  • It sure is possible.

    One way is to use a signed applet, but if your users are willing to upgrade to Java 1.6.0_10+, a signed applet is not needed. Since 1.6.0_10 (the Next Generation Java Plug-In), JNLP API services are available to embedded applets. Here is a demo. of the JNLP file services.

    I see the other reply has already covered the applet/JS interaction.