• Post Reply Bookmark Topic Watch Topic
  • New Topic

Access denied exception in applet  RSS feed

 
Karthik Krishnamurthy
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have written a web based application which calls an applet for the animation.
In my init() method I have the follwoing code :

Properties valueProperty = new Properties();
try{
valueProperty.load(new java.io.FileInputStream("resize.properties"));
}catch (Exception e){
System.exit(-1);
}

The exception i am getting is :
access denied (java.io.FilePermission resize.properties read)

I have all my class files in a jar file and even this properties file (resize.properties) is part of the jar
But somehow I am getting access denied.

Can someone pl. help. Its a project already a week overdue and I am stuck at this level now.

Thx
Karthik
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FileInputStream() tries to access the local disk, which is a security violation for applets. If the file is in the downloaded Jar file, then use getClass().getResourceAsStream(...) instead, to open a stream to the file in the applet jar file.

Henry
 
Karthik Krishnamurthy
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
thanks for the input.
However, in this case what would be the context root.
The code is in a file vdt.VDTApplet.
The properties file is in the root folder.
I tried both

valueProperty.load(getClass().getResourceAsStream("..\resize.properties"));
and
valueProperty.load(getClass().getResourceAsStream("resize.properties"));

but am getting NullPointerException in both cases.

Thx
Karthik
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"/resize.properties"
 
Karthik Krishnamurthy
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
thanks a lot. It workedl ike a charm.

Karthik
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!