Catalina - no "[app] would like to access files in your Documents folder" prompt in Java app

I develop a Java application that, when bundled as an .app, is unable to access the contents of the Desktop, Documents, and Downloads dirs from a specific type of file chooser (JFileChooser) in Catalina. Unlike other apps, no "[app] would like to access files in your [Desktop/Documents/Downloads] folder" popup appears when I attempt to access the contents of those directories via JFileChooser.


I can access the contents of those dirs with a different Java file chooser (FileDialog, which appears to use the native macOS chooser) - but there's no "[app] would like to access..." prompt there either.


Unlike every other app I've used in Catalina, there are no Desktop/Documents/Downloads access prompts for these Java apps.


I'm hoping to determine 1) why the prompt doesn't appear, and 2) how to make it appear if possible, or otherwise grant access to those dirs.


AFAICT there's no way to manually add an app to the Prefs > Security & Privacy > Privacy Tab > Files and Folders list. The +/- buttons remain disabled when I "Click the lock to make changes" and authenticate.


I created a minimal example app demonstrating the problem - source code and pre-built app bundle are available here:

https://github.com/sorghumking/catalinaFileChooserAccessTest


Any help would be greatly appreciated!

Replies

The +/- buttons remain disabled when I “Click the lock to make changes” and authenticate.

Indeed. That’s currently the expected behaviour — there’s no way to manually add or remove items in this list — but clearly this UI could do with some significant improvements. We already have a bug on file requesting that (r. 54299926).

I can access the contents of those dirs with a different Java file chooser (

FileDialog
, which appears to use the native macOS chooser) - but there's no “[app] would like to access...” prompt there either.

Right. That’s expected. When the user chooses an item via the standard file panels, the system considers that explicit authorisation for the app to access that file.

As to why your Java app isn’t triggering these alerts when it accesses the items without user approval, that’s hard to say. By definition this must be some sort of packaging issue because it works fine for native apps. My general advice is that you compare your app’s packaging against that of a standard app (just build a tiny test project in Xcode) to see what’s different.

The specific packaging issue that I’ve run into before is with apps that use a script for their main executable (that is, the file in

Contents/Macs/
that’s referenced by
CFBundleExecutable
). This is not a good idea in general, and it can cause exactly this problem.

However, I’m not sure that this is the only cause of this issue.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Many thanks for your helpful response!


Indeed, the CFBundleExecutable in the problem app is a script. When I swap that out for a compiled binary, the access prompts appear as expected in JFileChooser. (Sadly, the compiled binary introduces other problems, but that's another story and help thread!)

We are seeing the same problem on SOME OSX systems, but not all. OSX 10.15 and 10.16.
Adopt Open JRE 11.0.7
Doesn't seem to be OSX version or Java version dependent.

Ever since JAVA 15 I can not run JAVA applications to access the above directories. In fact, JAVA 15, 16 and 17 do not run my applications correctly, both on Catalina and Big Sur. The applications, i.c. the runtime system, ignores the grants already there from earlier JAVA releases and also do not ask for new permissions.

;JOOP!