aspose file tools
The moose likes Java in General and the fly likes What exactly Does <setExecutable()> Do on a Windows Machine? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "What exactly Does <setExecutable()> Do on a Windows Machine?" Watch "What exactly Does <setExecutable()> Do on a Windows Machine?" New topic
Author

What exactly Does <setExecutable()> Do on a Windows Machine?

Kevin Simonson
Ranch Hand

Joined: Oct 22, 2011
Posts: 40
I wrote a Java program that takes two arguments, creates a file using as name the first argument, and simply writes the second argument to that file and closes the file. After all this it calls <setExecutable( false)>, which I thought would make the file non-executable. The code follows.

When I run this with "java OneLine Jqz.Txt Jqz.", it creates file "Jqz.Txt" just fine, and it has contents a single line that says "Jqz.", but when I type in "ls -l Jqz.Txt" I get "-rwx------+ 1 kvnsmnsn Domain Users 6 Feb 10 09:36 Jqz.Txt". Why is the executable bit still set?

I should note that my machine actually has a Windows 7 Operating System; I get the "ls" command from Cygwin, which lets me emulate a lot of Unix commands. In fact I can type in "chmod ugo-x Jqz.Txt" and that does succeed in turning the executable bit off. But why doesn't <setExecutable()> turn the executable bit off?

Kevin Simonson
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 2686
Did you check the return value from setExecutable ? As it says in the javadoc
If executable is false and the underlying file system does not implement an excute permission, then the operation will fail.

Windows does not have the concept of an executable permission for files.


Joanne
Kevin Simonson
Ranch Hand

Joined: Oct 22, 2011
Posts: 40
Joanne Neal wrote:Did you check the return value from setExecutable ? As it says in the javadoc
If executable is false and the underlying file system does not implement an excute permission, then the operation will fail.

Windows does not have the concept of an executable permission for files.

I just checked the return value from <setExecutable()>, and it was <false>. I guess the underlying file system doesn't "implement an excute permission." Oh well.

Kevin Simonson
 
 
subject: What exactly Does <setExecutable()> Do on a Windows Machine?
 
Threads others viewed
Internationalization and Unicode
Why Won't a Simple Socket Program Work when a Windows 7 Machine Acts as Server?
Why does File renameTo() fails ?
Program mod w/o command line arguments
Accessing FTP Server using Java
IntelliJ Java IDE