This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Queries on Builiging a trusted Applet

 
dinesh Venkatesan
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42967
73
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you!!!
dinesh.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic