aspose file tools
The moose likes Java in General and the fly likes Under Java Security Manager, accessing a file inside a jar Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Under Java Security Manager, accessing a file inside a jar" Watch "Under Java Security Manager, accessing a file inside a jar" New topic
Author

Under Java Security Manager, accessing a file inside a jar

Sandeep P Kulkarni
Greenhorn

Joined: Sep 28, 2007
Posts: 5
How to read a file[resource] inside jar under Java Security Manager?
Ex- in myApp.jar , I want to read file placed under com/mystuff/queries/abc.sql
myApp.jar
|
|-com/mystuff/queries/abc.sql


I am using Class.class.getResourceAsStream("")to read the content of a file which is packaged inside a jar. This works fine if not run under Java Security manager. This fails under Java Security Manager. I am getting a NULL InputStream under security manager. Probably I need to give "read" permission to "queries" folder recursively.

What is the syntax to be used in policy file to give permission recursively to folder inside a jar?

OR Please let me know if this is the correct syntax-
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 681
Here's a copy of an entry from my .java.policy file:
grant codeBase "file:/D:/JavaDevelopment/Testing/ForumQuestions/-" {
permission java.io.FilePermission "C:/autoexec.bat", "read";
permission java.lang.RuntimePermission "queuePrintJob";
permission java.awt.AWTPermission "readDisplayPixels";
};
Sandeep P Kulkarni
Greenhorn

Joined: Sep 28, 2007
Posts: 5
Hi Norm ,

I want to give permissions to file packaged inside a jar.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Under Java Security Manager, accessing a file inside a jar
 
Similar Threads
Printer Applets that use Jar Files
JAAS and Policy files problems
How to view jar files
Run jar file
RAD - WAS6 Admin Console -Error page exception