I have an application which also can run as an applet. It uses
sun.misc.BASE64Decoder.
But when running it as an applet, I get
Java(TM) Plug-in: Version 1.4.2_01
java.security.AccessControlException: access denied
(java.lang.RuntimePermission accessClassInPackage.sun.misc)
I tried to circumwent this by coding
sun.misc.BASE64Decoder b64de=null;
try {
b64de = new sun.misc.BASE64Decoder();
} catch (/*java.security.AccessControl*/ Exception e) {
System.err.println(e);
b64de=null;
}
but this did not help because the exception is not generated by "new
sun.misc.BASE64Decoder();" but it is from the declaration of b64de,
i.e. from the class loader.
Is there anything that I can do to avoid this exception in the applet
while letting the code there for the application?
JMS
Michael Amling - 27 Feb 2004 18:00 GMT
> I have an application which also can run as an applet. It uses
> sun.misc.BASE64Decoder.
[quoted text clipped - 21 lines]
> Is there anything that I can do to avoid this exception in the applet
> while letting the code there for the application?
Have you tried reflection? That's what I use to invoke 1.4 features
if running in a 1.4 environment yet retain the ability to run on
customers machines that have only 1.3 installed.
--Mike Amling
J M Schlatter - 27 Feb 2004 20:04 GMT
> > Is there anything that I can do to avoid this exception in the applet
> > while letting the code there for the application?
>
> Have you tried reflection? That's what I use to invoke 1.4 features
> if running in a 1.4 environment yet retain the ability to run on
> customers machines that have only 1.3 installed.
I don't know why reflection would help but your posting guided me to
the right way: I think I have to use the class loader to load the
class only if it's not a 1.4 applet.
JMS
Roedy Green - 05 Mar 2004 01:46 GMT
>Is there anything that I can do to avoid this exception in the applet
>while letting the code there for the application?
Modify the policy file to give you permission. But then you have the
problem of distributing policy files. You can do a generic signed
applet that allows everything.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.