LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   File with Default Execution Permission (https://www.linuxquestions.org/questions/programming-9/file-with-default-execution-permission-4175515608/)

reza_zah1991 08-20-2014 03:09 PM

File with Default Execution Permission
 
hi folks
i have java programm that create a file
application needs exexution & Write permission for file
but in linux files have not a execution Permission by default


how can i configure the linux to creat a file with execution permission by default.. ???

thanks to all

cliffordw 08-21-2014 12:14 AM

Hi there,

As far as I know there is no way to set execute permission by default on a newly created file. You might be able to change the permissions from within your Java program after creating it, though. Which version of Java are you using? In Java 7, try setPosixFilePermissions() in the java.nio.file class.

Out of curiosity, any particular reason you need execute permission? This is an unusual requirement. What files are you creating that need this?

Regards,

Clifford

reza_zah1991 08-21-2014 12:42 AM

cliffordw

i am writing a project under cloud Computing Design,,
and admin user can add new function to the server and i want to compile the function before adding to the server
in linux when we create a file,, execution permission is not as default, for this reason i cant run the file for compile

setPosixFilePermissions() did worked..

thanks man..

reza_zah1991 08-21-2014 12:47 AM

at last i have a question

this Solution "Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>();"
is a OS Dependence or is universal Solution and work all right in all Operation System ????

cliffordw 08-21-2014 02:03 AM

Quote:

Originally Posted by reza_zah1991 (Post 5224509)
at last i have a question

this Solution "Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>();"
is a OS Dependence or is universal Solution and work all right in all Operation System ????

This works only on POSIX-compliant systems. This means it will work on Linux, most other UNIX systems, etc, but not on Windows.


All times are GMT -5. The time now is 12:25 PM.