Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Could someone take a look at this and tell me what am I doing wrong?

0 views
Skip to first unread message

Gustavo Seabra

unread,
Sep 3, 2001, 4:45:35 PM9/3/01
to
I'm sorry to bother you again, but I tried to build this little applet
that works ok with appletviewer, but never when using a browser. I tried
using the htmlconverter, but it doesn't help. I've put it in a web page,
hoping that someone here could take a look and tell me what's wrong. The
address is:

http://home.swbell.net/gseabra/java/PeteApplet.html

From what I got when I first posted about it two days ago, it seems that
the problem is that I'm trying to read files from my computer, and it gives
a security error. But when I put all files in the web-server, the error
continues. When in Netscape 6.0 the Java console gives the following:

**********************
java.security.AccessControlException: access denied (java.io.FilePermission
right1.gif 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 PetePanel.<init>(PeteApplet.java:32)
at PeteApplet.<init>(PeteApplet.java:5)
at java.lang.Class.newInstance0(Native Method)
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)
**********************

Any ideas would be greatly appreciated.
Thanks,
--
-----------------------------------------------------------------
Gustavo Seabra - Graduate Student
Chemistry Department
Kansas State University
-----------------------------------------------------------------


Chris Smith

unread,
Sep 3, 2001, 11:26:54 PM9/3/01
to
Gustavo Seabra wrote ...

> From what I got when I first posted about it two days ago, it seems that
> the problem is that I'm trying to read files from my computer, and it gives
> a security error. But when I put all files in the web-server, the error
> continues.

This will continue to be true so long as you write code that looks for
the file on the client. The difference is that now, even if the security
check could succeed, you wouldn't find the file because you're looking in
the wron place. From the stack trace:

> When in Netscape 6.0 the Java console gives the following:
>
> **********************
> java.security.AccessControlException: access denied (java.io.FilePermission
> right1.gif 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 PetePanel.<init>(PeteApplet.java:32)

[...]

Looks like you're calling getImage on the java.awt.Toolkit
implementation. Not a good idea, as that will look locally. If you
check the API docs, you'll find that the Applet class has its own
getImage method that will look in reasonable locations for an applet and
load the image from the server.

Chris Smith

entaylor.ignorethispart.@cloudnet.com

unread,
Sep 3, 2001, 11:34:59 PM9/3/01
to
> From what I got when I first posted about it two days ago, it seems that
>the problem is that I'm trying to read files from my computer, and it gives
>a security error. But when I put all files in the web-server, the error
>continues. When in Netscape 6.0 the Java console gives the following:

There is a bug in Netscape 6.0 that prevents a scripted applet from making a
socket call. We were hoping that it would be fixed in 6.1, but it isn't.

There are details about this bug in Bugzilla somewhere.

If you try it in 4.7 it should work fine.

Ned Taylor
Dr. Departure Software

0 new messages