Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

File Acess in java

  Asked By: Bertha    Date: Sep 12    Category: Java    Views: 593
  

I've got a problem here.When trying to use the File class for use in an applet I
get an exception 'com.ms.security.SecurityException' saying I cannot access the
file I'm trying to use.The applet compiles on Visual J++, but the web-browser
gives me this message when I try to load it up on the web page.How do I solve
this problem?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Isra Demir     Answered On: Sep 12

If you mean a file  on the local machine, you won't be able to consult
it from within an applet, which runs in a security-
protected "sandbox". If you mean a file on the server, you need to
set the codebase in the web  page, i.e.

<applet width="200" height="50" code="Applet.class"
codebase="."></applet>

and put the file in the same folder as the applet. Also, avoid J++
if you can help it!

 
Answer #2    Answered By: Abrianna Rossi     Answered On: Sep 12

Can't you use the Policy class  to grant specific kinds of
privileges to local file  systems?

 
Answer #3    Answered By: Damon Jones     Answered On: Sep 12

If you download the applet  and then run it using the appletviewer
instead of in the browser, the Applet is allowed to read certain
files, which are marked on the access  control list. If you only use
the browser, the Applet will have to be signed by a party marked as
trusted before it is allowed to access any files.

See http://java.sun.com/sfaq/ for more on security.

 
Didn't find what you were looking for? Find more on File Acess in java Or get search suggestion and latest updates.




Tagged: