Application Support directory to classpath

Michael Hall mik3hall at gmail.com
Fri Mar 11 09:47:32 UTC 2016


> On Mar 11, 2016, at 1:23 AM, Hendrik Schreiber <hs at tagtraum.com> wrote:
> 
> Hey Michael,
> 
>> On Mar 11, 2016, at 02:51, Michael Hall <mik3hall at gmail.com> wrote:
>> 
>> I am trying to add some support for my application updating external files. Appstore is not necessarily a major concern, but I wouldn’t want to eliminate it as a possibility for no good reason by doing something unnecessarily violating some app store constraint. In some quick browsing I saw no real better choice to place the data than using the Application Support directory. If there is a better way of handling that now please let me know. 
> 
> 
> When your app is sandboxed, it does not have access to Application Support.
> Instead, it has its own “container”. Read more about this at https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW15 <https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW15>
Thanks, my understanding of this should be better. I’ll take a look at this.


> To migrate later, take a look at 

Thanks again.

> To find the Application Support directory, you can use
> 
> import com.apple.eio.FileManager;

I do have code like this. So for one thing it was good to see recently that the java 9 effort has found a good home for FileManager going forward. The problem is it’s not possible to reflect code like this into a static properties file. So for the code I’m looking at I was considering the approach of just supplying a file name and not a path, then if I follow the code right it will fallback to looking for the filename in class path. So if I get it into a Application Support directory that is in class path, it should work.

> Whether System.getProperty("user.home”) will return the container directory for a sandboxed app is an interesting question that I don’t know the answer to. The Objective-C docs recommend to use https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/index.html#//apple_ref/c/func/NSHomeDirectory to get it.

user.home I generally don’t use. Though, I am pretty used to it always being /Users/<user name>. user.dir has moved around a little bit over the years for java. Given sandboxing or App Store is not a concern then either would probably be ok to use. More properly these days, if you do have sandboxing or App Store  concerns I have assumed you should not count on properties like this to access external files anymore, period.

Maybe someone else can answer the question of whether or not this has been considered for sandboxed java applications so that you actually do get something different for these properties that is usable?

Michael Hall






More information about the macosx-port-dev mailing list