Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

java .security .AccessControlException

 
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all the ranchers
When I run the JApplet in the browser,the status bar in the browser give me java.security.AccessControlException: access denied (java.io.FilePermission i.gif read)
The first question is
Could the JApplet run on browser without putting it in server?
And
How can I cope with the problem?
thanks for your time to answer
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sui,
Could the JApplet run on browser without putting it in server?
yes. u write the applet on ur machine.
prepare the HTML file.
view it on local browser.
also, the image that the JApplet is trying to get "i.gif" is where? do u have a jar file for the applet? if u have the jar file then u can put ur image in that jar file and get the iamge via getResourceAsStream() or something from the applet instead referring to the file directly via,
Image img = new Image("i.gif") u know...
regards
maulin
 
Francis Siu
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Maulin
thanks you for reply
the image that the JApplet is trying to get "i.gif" is where?
In the same folder of that html and the required class.
I do not know why I can not read the .gif file

Actually,I can run on the JBuilder but I can not run on local browser.
do u have a jar file for the applet?
No.
Do I need to make a jar file for the JApplet?
thanks for your attention
 
Francis Siu
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A little bit confuse of the following


checkPermission
public void checkPermission(Permission perm)
throws AccessControlExceptionDetermines
whether the access request indicated by the specified permission should be allowed or denied, based on the security policy currently in effect, and the context in this object.
This method quietly returns if the access request is permitted, or throws a suitable AccessControlException otherwise.

Parameters:
perm - the requested permission.
Throws:
AccessControlException - if the specified permission is not permitted, based on the current security policy and the context encapsulated by this object.


Can I override the above method so that I can set the permission of the action
But I do not know the object reference of the Permission object,Can I use Permission object point to the pathname of a file?

Most Permission objects also include an "actions" list that tells the actions that are permitted for the object. For example, for a java.io.FilePermission object, the permission name is the pathname of a file (or directory), and the actions list (such as "read, write") specifies which actions are granted for the specified file (or for files in the specified directory). The actions list is optional for Permission objects, such as java.lang.RuntimePermission, that don't need such a list; you either have the named permission (such as "system.exit") or you don't.


please help me how do I need to do.
thanks
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!