Re: How to make a file "executable" at runtime?

From: Anthony Borla (ajborla_at_bigpond.com)
Date: 02/23/05


Date: Wed, 23 Feb 2005 16:08:50 GMT


"bfische" <fischelbruno2@hotmail.com> wrote in message
news:1109131163.156740.268830@z14g2000cwz.googlegroups.com...
> I am creating a script file in some Java class.
>

Dynamic programming at it's best ;) !

>
> I want to change its permission so it can be executed
> using Runtime.exec().
>

See below regarding file permissions.

>
> I have tries to create a new FilePermission for this file and
> then use:
>
> AccessController.checkPermission(myFilePermission) but
> I get an AccessControllerException with access denied.
>
> Is it possible to give my file the execute permission with
> Java (I would like to avoid having to run a chmod)?
>

The FilePermission 'execute' permission simply allows 'Runtime.exec' to
launch the nominated file [which should be a binary executable]. It is
something which is applicable only within the Java environment, and has
nothing to do with *NIX file permissions.

So the answer is: no, you cannot use a standard Java class to directly
perform this task. You will need to use 'chmod', either in command form,
executed via 'Runtime.exec()', or in function form, via a JNI wrapper.

I hope this helps.

Anthony Borla



Relevant Pages

  • How to make a file "executable" at runtime?
    ... I am creating a script file in some Java class. ... Is it possible to give my file the execute permission with Java (I ...
    (comp.lang.java.programmer)
  • Re: System.Security.SecurityException was unhandled
    ... The exception gave you the CLSID. ... the first thing to check might be whether the COM server ... assembly actually has the permission in question. ... When I execute the application I received and error message. ...
    (microsoft.public.dotnet.security)
  • Re: System.Security.SecurityException was unhandled
    ... assembly actually has the permission in question. ... Try and find the sorce of the security permission error, ... setting was done on both versions 1.1 and 2.0 .NET framework. ... When I execute the application I received and error message. ...
    (microsoft.public.dotnet.security)
  • Re: System.Security.SecurityException was unhandled
    ... Is it a must that I need to register the COM server to the machine using ... CAS permissions on the client machine, and the COM issue is a new problem. ... assembly actually has the permission in question. ... When I execute the application I received and error message. ...
    (microsoft.public.dotnet.security)
  • Re: SQL CLR Sproc isnt running right
    ... did you grant rights using the SQL Server 2005 Surface Area Config tool? ... and I got a permissions error back saying DBO doesn't have permission to insert records into the table... ... but the assemblie's stored procedures do all have execute permissions set for the role that the executing user is in... ... "William Vaughn" wrote in message ...
    (microsoft.public.dotnet.framework.adonet)