• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Queries on Builiging a trusted Applet

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

While going through the FAQ section of sun i found this point.

Can applets read or write files?
In Java-enabled browsers, untrusted applets cannot read or write files at all. By default, downloaded applets are considered untrusted. There are two ways for an applet to be considered trusted:

1The applet is installed on the local hard disk, in a directory on the CLASSPATH used by the program that you are using to run the applet. Usually, this is a Java-enabled browser, but it could be the appletviewer, or other Java programs that know how to load applets

Can anybody give me some more input on this. I tried saving my Applet that tries to write a File in the directory that is specified in the ClassPath but it does not work.

Thanks in Advance!!!
dinesh
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I tried saving my Applet that tries to write a File in the directory that is specified in the ClassPath but it does not work.



First of all, what does "it does not work" mean? Are there any exceptions in the Java Console? If so, which ones?

Is the applet properly initialized, i.e. does the init method finish without problems?

How are you running this applet - with appletviewer, with a file:/// URL in a browser or from a web server?

What does "saving the applet" mean?

Answering these questions will let us help you track down the problem.
[ January 10, 2007: Message edited by: Ulf Dittmer ]
 
dinesh Venkatesan
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer for Question What do i mean by "it does not work"?
Yes, I am getting some exceptions.
java.security.AccessControlException: access denied (java.io.FilePermission Secu
rity.sec write)

Answer for the Question "Is the Applet properly Initialized?"

Yes, the Applet is properly initialized and started since I have placed the code to access File in the paint method.

Regarding Executing the applet.

I have used the appletviewer to run the Applet.

I meant I have made a copy of the Applet class and source in a directory that is present in the ClassPath by the statement saving the applet.

Thanks,
dinesh.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your Java installation may have a security policy that enforces the applet restrictions even for local applets. A starting point for learning about policies can be found here. Make sure that the policy in force allows applet file access.

I have placed the code to access File in the paint method.


That's not such a good idea. The paint method can be called many times, which would lead to the file being read over and over - is that what you want?
 
dinesh Venkatesan
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you!!!
dinesh.
 
Men call me Jim. Women look past me to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic