Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can an applet access a file ??

843785Jul 25 2008 — edited Jul 26 2008
I have written an applet in Netbeans and it is working ok.. Now I need to embed this applet in an html file. I have used the following code for doing so :
<Html>
<Head>
<Title>Java Example</Title>
</Head>

<Body>
This is my page<br>
Below you see an applet<br>
<br>
<Applet Code="MyApplet.class" width=200 Height=100>
</Applet>
</Body>
</Html>
Now when i run the html file.. the applet does not run. It gives an error called Applet notinited.

Java console contains this :
java.security.AccessControlException: access denied (java.io.FilePermission C:\postplotter.txt read)
	at java.security.AccessControlContext.checkPermission(Unknown Source)
	at java.security.AccessController.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkRead(Unknown Source)
	at java.io.FileInputStream.<init>(Unknown Source)
	at java.io.FileInputStream.<init>(Unknown Source)
	at java.io.FileReader.<init>(Unknown Source)
	at finalpkg.trial.init(trial.java:54)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Please help. I think the problem is because the applet needs to access this file called C://postplotter.txt

Edited by: sauvikc on Jul 25, 2008 7:33 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2008
Added on Jul 25 2008
21 comments
329 views