Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Strange java applet error message

Strange java applet error message
Thread Tools
Dedicated MacNNer
Join Date: Aug 2004
Status: Offline
Reply With Quote
Mar 4, 2005, 02:27 PM
 
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.
     
maCCer  (op)
Dedicated MacNNer
Join Date: Aug 2004
Status: Offline
Reply With Quote
Mar 4, 2005, 02:29 PM
 
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.
     
maCCer  (op)
Dedicated MacNNer
Join Date: Aug 2004
Status: Offline
Reply With Quote
Mar 4, 2005, 02:30 PM
 
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
Reply With Quote
Mar 4, 2005, 05:22 PM
 
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.
     
maCCer  (op)
Dedicated MacNNer
Join Date: Aug 2004
Status: Offline
Reply With Quote
Mar 5, 2005, 03:11 PM
 
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
Reply With Quote
Mar 7, 2005, 02:12 PM
 
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
     
maCCer  (op)
Dedicated MacNNer
Join Date: Aug 2004
Status: Offline
Reply With Quote
Mar 7, 2005, 05:08 PM
 
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
Reply With Quote
Mar 8, 2005, 03:37 PM
 
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
Reply With Quote
Mar 9, 2005, 08:12 AM
 
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.
20" iMac G5! :D AND MacBook 1.83GHz!
Canon Digital Rebel Kit + 75 - 300mm lens. Yum Yum! :D
Check out my OS X Musical Scales program
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:13 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2