Question

I was in the process of turning my jar that reads and writes files into an applet. It displays properly until I add in the read and write function. Then Firefox just shows a black box (no error popups).

I have done a lot of research and it seems in order to get it to work I need to have the applet signed and then it will ask the user for permission, however I also read that I can't make an applet write files and it must be server side.

So my question is can I make an applet read and write files without sever side scripting? and if so how do I get my applet signed (I read some tutorials but I'm kinda new to this).

Was it helpful?

Solution

An applet that is signed can read and write files on the local machine.

There are two types of certificates that you can use, the first is a certificate you create with keytool, an app that comes with the JDK. The second option is to sign an applet with a certificate from a Certificate Authority like Verisign.

The difference is that the self made certificate will show warning messages to the client specifying that the certificate isn't trusted. This is just a warning, but can scare users. The downside of a certificate from a real certificate authority is that it cost money.

To generate a certificate use keytool -genkey

then to do the signing, it depends how you build your applet.

For instance if you use Ant, there is a signjar task that will sign the applet.

OTHER TIPS

So my question is can I make an applet read and write files without sever side scripting?

Sure, and in a 1.6.0_10+(1) JRE (the 'Next Generation' plug-in), it does not even require the Jars to be digitally signed.

An applet deployed using Java Web Start in a next gen. plug-in has access to the JNLP API services. The FileContents object of the API provides basic I/O. Here is a demo. of using the FileContents (the source is also available at the link).

(1) Note: JWS could launch free-floating applets since Java 1.2. But with 1.6.0_10+ a JWS applet can remain embedded in a browser window (for Win. & *nix at least - I hear 'no Mac.').

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top