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.
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.
Joined: Mar 22, 2005
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?