To no avail, I've tried:
making a JAR file, and including it in the html
editting java.policy.applet with explicit FilePermissions
TIA,
Rob
Generally speaking, within an applet, you can only access files using URLs,
to access the directly as files, you will need to sign your applet and have
the user grant you the appropriate permissions.
"Rob Jaeger" <yogi...@yahoo.com> wrote in message
news:Xns93F06D8B4A447...@24.168.128.90...
> Can you post the code that is trying to access the files?
> And post and exception that is being generated?
>
> Generally speaking, within an applet, you can only access files using
> URLs, to access the directly as files, you will need to sign your
> applet and have the user grant you the appropriate permissions.
>
OK- I don't want to have a signed applet. I just need to read graphics
files. I was hoping that just using the filename was good enough.
The offending code:
// board
static Image imageBoard =
Toolkit.getDefaultToolkit().getImage("board.jpg"); /* fails in
browser, OK in Eclipse */
It doesn't work at all if I specify the full URL (syntax error???):
static Image imageBoard =
Toolkit.getDefaultToolkit().getImage
("http://www.normaldistribution.com/PokerCalc/board.jpg");
error (from Java Console):
java.security.AccessControlException: access denied (java.io.FilePermission
board.jpg read)
Full Java Console output:
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied
(java.io.FilePermission board.jpg read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at sun.awt.SunToolkit.getImageFromHash(Unknown Source)
at sun.awt.SunToolkit.getImage(Unknown Source)
at aFont.<clinit>(aFont.java:49)
... 11 more
java.lang.NoClassDefFoundError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
>OK- I don't want to have a signed applet. I just need to read graphics
>files. I was hoping that just using the filename was good enough.
However, if the system let you read that file, you could go looking at
the user's porn collection just as easily. That would be quite and
embarrassing thing for an enemy to be able to do.
That is why there are signed Applets and why your Applet can't go read
an arbitrary file without permission.
It is not that hard. See
http://mindprod.com/jgloss/signedapplets.html
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Can we see some code? More specifically, any code involving the
instantiation of the Image object, and all references to it? Also,
what environment are you working in? *nix? What are your permissions
for the JPEG? should be readable by everyone.
> On Mon, 08 Sep 2003 16:58:10 GMT, Rob Jaeger <yogi...@yahoo.com>
> wrote or quoted :
>
>>OK- I don't want to have a signed applet. I just need to read graphics
>>files. I was hoping that just using the filename was good enough.
>
> However, if the system let you read that file, you could go looking at
> the user's porn collection just as easily. That would be quite and
> embarrassing thing for an enemy to be able to do.
Thanks, Roedy. I understand the security situation. For this applet, I
just need to load some graphics files that reside on the server with the
.html and the .class. The graphics load fine from html, and the file
permissions are fine.
When I use the full URL like this:
static Image imageBoard =
Toolkit.getDefaultToolkit().getImage
("http://www.normaldistribution.com/PokerCalc/board.jpg");
it fails even in the Eclipse environment. Is there something wrong with
my syntax? You can see that the URL works.
Thanks for your help & patience,
Rob
>Thanks, Roedy. I understand the security situation. For this applet, I
>just need to load some graphics files that reside on the server with the
>.html and the .class. The graphics load fine from html, and the file
>permissions are fine.
the easiest way to do that is to put them in the jar and get them with
getResource.
The usual way you trip over security is trying to pick them up from a
different server from the one that loaded the Applet.
Here is your problem. You need to use the URL class to specify the URL,
passing the file name into the URL constructor, and passing the URL object
into getImage().