Jump to content

[Solved] permission denied to write file in home directory


Recommended Posts

Posted

in jsp

 
 
 
 
 
String strPath = "/home1/rajesha1/file.txt";
 File strFile = new File(strPath);
 boolean fileCreated = strFile.createNewFile();
 //File appending
 Writer objWriter = new BufferedWriter(new FileWriter(strFile));
 

 

 

 

 

 

java.io.FileNotFoundException: /home1/rajesha1/file.txt (Permission denied)

 

Posted

Tomcat runs as a different user. Try creating a folder inside your home folder, granting it 757 for its permissions (instead of the default 755), then saving the file inside the new folder.

 

The folders where your Java app saves its data needs "other" write permissions, since Tomcat is not running as you and is not in the same group.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...