Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting permissionsin policy file and using threads

Status
Not open for further replies.

crazyme207

Programmer
Apr 18, 2003
1
US
I have written the following code:
Code:
//this is saved in /home/myname/main/second/

package second;
public class secThread extends Thread{
public void run(){
FileWriter fw = new FileWriter("file.txt");
fw.close;
}
}
-------------------------------
Code:
//this is saved in /home/myname/main/
import second.secThread;
public class mainProg{
public static void main(String args[]) {
secThread st = new secThread();
st.start();
}
}
----------------------------------
my policyfile has the following entry"
Code:
grant codeBase "file:/home/myname/main/*"
 permission java.io.FilePermission &quot;<<ALL FILES>>&quot;;
};
notice, secThread does not have permission to write to anyfile
---------------------------------
when i run mainProg, using the default security manager and the policyfile above, i do not get an exception. However, I think I should because secThread is writing to a file, but it does not have java.io.FilePermission, &quot;write&quot; to write to any file!

Can someone please help me out here?
I am using JDK1.3

Thanks
SG
 
By default, on a local system, all threads have write permission. You might be able to use a policy file to take away this permission (I've never tried).



&quot;When you have eliminated the impossible, whatever remains, however
improbable, must be the truth.&quot; ~ Arthur Conan Doyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top