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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...