I have a weird question. I'm trying to access a .txt file from a java applet, which would reside locally. When running this with the applet viewer, everything works fine. When you click on the .html file, however, you get an accesscontrolexception. I find it weird that the applet viewer works fine, but when you actually click on the .html file, it doesn't work right. Is there a reason for this?

PS: Do you REALLY need to sign an applet that uses a local file?

Recommended Answers

All 4 Replies

When you use the appletviewer you're not restricted by the security limitations imposed on applets.
When you run it in a browser you are so restricted.

One of those restrictions is the inability to access any data that doesn't reside in the same location as the applet itself (which includes locations on your own harddisk when running it from there which are outside the classpath of the applet).

Yes, you do need a signed applet with a valid security certificate that is authorised by your users.

So the only thing the user will see is a 'certificate' that they can click ok or yes to, right? I thought I read something last night that involved passwords and stuff.

yes, the user only has to accept the certificate.
For you it's more involved as you have to create it.
There's a tool included to make test certificates but for real use you're going to need an external party like Thawte which will cost money (I'd not trust a self-signed applet...).

Thanks for all the help. I'm not too worried about users not trusting it, since no one will probably ever look.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.