java.io.FileNotFoundException (permission denied) despite chmod 777

FileNotFoundException occurs:

when a file with the specified pathname does not exist. It will also be thrown if the file does exist but for some reason is inaccessible, for example when an attempt is made to open a read-only file for writing.

File is there and it has write rights according to what you sent.

In some cases, if the file that you are trying to access for read/write operation is opened by another program then this error will occur. Use lsof | grep the-file-name.txt to see if it is open.


Finally I have solved the problem. One of the directory in path haven't executable permission for other group, so as @JustinKSU suggested, there was no possibility to go throught whole path.

chmod o+x /home/user solved the problem.


Ensure you that you have read and execute access to all parent directories as well.

Example: chmod o+x /home/user