 |
 |
Strange java applet error message
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
i need load one image from somewhere of my computer, following is the code:
import java.awt.*;
import java.applet.*;
import java.awt.image.*;
public class trre extends Applet {
static final String message = "Hello World!";
public Image img;
public void init() {
setLayout (null);
img=getImage(getCodeBase(),"/Users/maCCer/Cs Study/2003/pic/lisa.jpg");
}
public void paint (Graphics g) {
g.drawImage(img,0,0,this);
}
}
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
But when i try to run it on my mac, i always got error message:
java.security.AccessControlException: access denied (java.io.FilePermission /Users/maCCer/Cs Study/2005/pic/lisa.jpg read)
at java.security.AccessControlContext.checkPermission (AccessControlContext.java:269)
at java.security.AccessController.checkPermission(Acc essController.java:401)
at java.lang.SecurityManager.checkPermission(Security Manager.java:524)
at java.lang.SecurityManager.checkRead(SecurityManage r.java:863)
at sun.awt.image.URLImageSource.<init>(URLImageSource .java:37)
at sun.applet.AppletImageRef.reconstitute(AppletImage Ref.java:33)
at sun.misc.Ref.get(Ref.java:46)
at sun.applet.AppletViewer.getCachedImage(AppletViewe r.java:377)
at sun.applet.AppletViewer.getImage(AppletViewer.java :372)
at java.applet.Applet.getImage(Applet.java:236)
at java.applet.Applet.getImage(Applet.java:258)
at trre.init(trre.java:22)
at sun.applet.AppletPanel.run(AppletPanel.java:353)
at java.lang.Thread.run(Thread.java:552)
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
HOWEVER, when i run it in my WINDOWS machine, everything is work, so can someone ive me a help?
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Feb 2005
Status:
Offline
|
|
Where does the image reside when you run it on the Windows system? This message:
java.security.AccessControlException: access denied (java.io.FilePermission /Users/maCCer/Cs Study/2005/pic/lisa.jpg read)
Clearly points to a permission problem. You don't have permission to read the file.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
Originally posted by __^^__:
Where does the image reside when you run it on the Windows system? This message:
java.security.AccessControlException: access denied (java.io.FilePermission /Users/maCCer/Cs Study/2005/pic/lisa.jpg read)
Clearly points to a permission problem. You don't have permission to read the file.
I have check the INFO for that pic, it shows we can READ and WRITE, so what is worngwith the permission?
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
I am not sure, but I believe that the java security model says that Applets cannot access the file system. If you want to access the file system, create a java application instead.
I've not ever written any applets, but I think I remember reading that this was the case.
|
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Aug 2004
Status:
Offline
|
|
Originally posted by Arkham_c:
I am not sure, but I believe that the java security model says that Applets cannot access the file system. If you want to access the file system, create a java application instead.
I've not ever written any applets, but I think I remember reading that this was the case.
thank you 
|
|
There were once four people named Everybody, Somebody, Nobody and Anybody. Somebody had to do a job, but Nobody wanted to do it. Nobody could see that Anybody could do it, and Somebody got angry about that because it was Everybody's job. Nobody ended up doing it, and it so happened that Everybody blamed Somebody when Nobody did what Anybody could have done.
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Feb 2005
Status:
Offline
|
|
Originally posted by Arkham_c:
I am not sure, but I believe that the java security model says that Applets cannot access the file system. If you want to access the file system, create a java application instead.
I've not ever written any applets, but I think I remember reading that this was the case.
Good catch, I forgot about that  Although it makes you wonder why it works on windows. 
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2001
Location: Deer Crossing, CT
Status:
Offline
|
|
Also, there is a space in your /CS Study/ directory. You might need to reference this directory like so: /CS\ Study/ in order for it to pass properly.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|