-
Notifications
You must be signed in to change notification settings - Fork 167
No JFileChooser Documents/Desktop/Downloads access prompt in macOS 10.15 Catalina #85
Comments
EDIT: The Apple forum link is dead in the wake of Apple's recent WWDC forum revamp. Thanks to helpful Apple forum folk, I've learned that this behavior is the result of using a script as an app's CFBundleExecutable. If I swap in a compiled binary for the CFBundleExecutable, access prompts ("[app] would like to access files in your Documents folder") appear as expected in JFileChooser. I'm guessing there isn't a way to translate the universalJavaApplicationStub script into a compiled binary? :-) |
Hi. I am having the same problem. I don't really want to move away from JFileChooser as that will be a lot of work across several apps, and from I can see file filtering does not work well in FileDialog across platforms. But a quick hack to use FileDialog as a test in one of my apps verifies that FileDoalog does show files instead of me getting a blank list in JFileChooser. Interestingly, even through the JFileChooser dialog is blank, I can actually load files which are under directory and are in my applications file history. Is there a solution for this? JFileChooser works when I run the application inside Eclipse as an EclipseLaunch configuration This is on OS X Catalina for me and AdoptOpenJDK/JRE 11 |
This isn't a fix, but it's an interesting observation: I develop an application which gives the user the option to use either java.awt.FileDialog or javax.swing.JFileChooser according to taste. I've seen the same; users can see these directories if they use FileDialog, but not if they use JFileChooser. However, I've had reports that if you use FileDialog to look at the offending directories, then subsequent uses of JFileChooser from the same application can see them too, "at least within that session, although it does remember it across sessions too, after a while". I can't verify this personally, since I don't have Macs to play with. |
Hi, I have just tried that, as my other dialogs in the application were still based on JFileChooser. So I opened the app, used the hacked file open first (FileChooser)m and then tried another file function (JFileChooser), and that does not seem to be the case. |
In the minimal app I built to demonstrate the problem: https://github.com/sorghumking/catalinaFileChooserAccessTest/releases I don't see the behavior you describe. Files in e.g. Documents are accessible in FileDialog, but remain inaccessible in JFileChooser after viewing in FileDialog. In the case of my app, the "[app] would like to access files in your Documents folder" prompt never appears. This is apparently a consequence of using a script (universalJavaApplicationStub) to launch the app. I'd guess that if the prompt appears and access is granted, files would become accessible in JFileChooser as well. |
I also had no problems when running the app from VSCode - they only occur when running a proper app bundle. I resolved the issue in my app by using the binary stub from this fork of Oracle's AppBundler: AFAICT, there is no way to resolve the issue when the app is launched with a script like universalJavaApplicationStub. |
OK, I admit the FileDialog-fixes-JFileChooser thing sounded quite surprising to me. As I say, I can't vouch for it personally. There may be something strange about either my application or the way it's being used. If anybody wants to check it out, the full report was:
and the bundled application is at http://www.starlink.ac.uk/topcat/topcat-full.dmg, but maybe the report was wrong. |
Thanks, I was actually thinking along the same lines for now, as that is how I originally got my application launcher for JRE7 until it stopped working under later OS X versions and I moved to universalJavaApplicationStub. |
Thanks for reporting this issue and sorry for the delay in answering... I can partly reproduce this on 10.15.5 with your test app using Java 10 (will test other Java versions later on...). Long long time ago I moved away from First I thought you could work around this by setting one of the new Security Plist Keys for macOS 10.15 for Pretected Resources Access (https://developer.apple.com/documentation/bundleresources/information_property_list/protected_resources) – like I tried anyways with <key>NSDownloadsFolderUsageDescription</key>
<string>Download Access</string> but neither of the dialogs showed the new Catalina security dialog like this:
Unfortunately I cannot access the linked Apple developer forum thread for further research.
Haven't heard of a way to compile bash scripts yet :-( That said, I did a quick research (https://lmgtfy.com/?q=compile+a+bash+script ;-) ) and clicked the first link https://www.simplified.guide/bash/compile-script, read about The result is a So I may consider releasing binaries from now on on my releases page... I added an issue for this (#87) to not forget the task... |
Cool. I will try the same myself to see if it resolves the issue. I have been looking at packing the JRE as a rather heavy handed workaround, but whilst I have it working, it raises its own issues. I had thought about migrating away from JFileChooser, but that would also entail a lot of works and checks, and unless I was missing the obvious choosable file filters looked more painful on FileDialog. Anyway if we can create an executable from the script that is the path of least resistance for me. :) I will try that as soon as I get time. |
Would you be able to test my test binary release? ;-) universalJavaApplicationStub-3.0.6-darwin-x86_64.zip This ZIP file contains the source and binary of version 3.0.6:
I compiled on macOS 10.14.6 with These are the
You can verify them after download with |
You would need to use the binary |
Sure thing. I will try it now.... |
Works perfectly. The folder AN1x is under my Documents folder, and using the script I was just getting the blank directory just as the OP reported. With the compiled binary in place of the script inside my APP package then I now get this Which enables this Thanks for the prompt attention. It will be much quicker for me to adopt this as the solution as my path of least resistance. |
Awesome! 👏 Thanks for testing it so quickly! 🏅 💯 Glad it works for you... I will officialy release binaries starting with the next 3.0.7 release. I'm also updating the README right now. |
No problem. I am much happier to go with this as the solution. I have never embedded the JRE in my apps as I have eight of them with packages for MAC, Windows and Linux, so 24 uploads all around 25MB each, and I live in an area with appalling broadband speed (much better now I am using 4G broadband, but still not super fast), so ~600MB of uploads if I do a common release. Embedding the JRE would triple that amount. On the plus side, I know how to embed the JRE if needed, but it is so much faff and the tools are still immature that I am much happier to stick with the launcher now you have a solution. So thanks for that. |
This is excellent, I'm so glad a fairly straightforward solution was found. (My apologies for the now-broken link to the Apple Developer forums where I received the initial clue regarding scripts vs. binaries. It appears my post got blown away in their most recent forum revamp.) |
Important note: From my latest experiments with Can someone test the binary above (#85 (comment)), which was compiled on 10.14, on macOS 10.13 or lower and report whether it's the same issue - app's not running? |
I opened an issue in the |
Just FYI I had all the issues here with OmegaT: script-based launcher, couldn't get the Catalina permissions prompts. We ended up moving to https://github.com/TheInfiniteKind/appbundler, but in the meantime I discovered that granting So when people report that "it works when I launch it from x", that means that x is a process owned by a binary that is able to request the permissions. The idea of compiling our script never occurred to me; it's very clever, and if you can get it working with as broad compatibility as you're aiming for, then I will consider switching to this project in the future. Thanks everyone for the great info in this thread. |
Binary releases are now published to the releases page of this repo starting with v3.1.0 (to be released in a couple of minutes)... |
Version 3.1.0 has officially been released 🎉 Details: https://github.com/tofi86/universalJavaApplicationStub/releases/tag/v3.1.0 |
forgot that in the release. now fixed: |
@tofi86 Sorry to comment on a closed issue, but have you tried using I'm using it to create a binary out of our launcher Bash script (which is admittedly much simpler than yours). Something like this:
It's probably excessive setting it for 10.10 (Yosemite) but figured I'd go with that since it's what our target JVM (AdoptOpenJDK) supports. I've tested on Sierra up through Big Sur with no problems so far, though. |
I'm submitting a…
Short description of the issue/suggestion:
First, thank you for sharing your universalJavaApplicationStub. It enabled us to get Corelyzer running against Java 8+ on Mac.
Since using the stub, however, we've noticed an issue unique to macOS 10.15 Catalina. Bundled apps with the stub cannot access the Documents, Desktop, or Downloads folders through the JFileChooser. Unlike other apps, the macOS system prompt "[app] would like to access files in your Documents folder" introduced in macOS 10.15 Catalina does not automatically appear.
I'm not certain this is due to the stub, but I only see the behavior in bundled apps that use it. If it is not the stub, any guidance you can provide would be greatly appreciated.
I should also note that those dirs are accessible (without prompts) through FileDialog, which appears to use the native macOS chooser. That said, I'd like to understand and resolve the JFileChooser issue, if possible.
Steps to reproduce the issue/enhancement:
Build and run the sample app demonstrating the problem here:
https://github.com/sorghumking/catalinaFileChooserAccessTest
Or download and run the pre-built app here:
https://github.com/sorghumking/catalinaFileChooserAccessTest/releases
What is the expected behavior?
When attempting to access contents of the Documents, Desktop, or Downloads dir in JFileChooser, macOS should prompt "[app] would like to access files in your [folder name] folder".
What is the current behavior?
No prompt appears. The contents of the Documents, Desktop, and Downloads folders are not displayed.
Do you have screenshots, GIFs, demos or samples which demonstrate the problem or enhancement?
I've created a minimal sample app demonstrating the problem here:
https://github.com/sorghumking/catalinaFileChooserAccessTest
Screengrab:
What is the motivation / use case for changing the behavior?
Again, am I uncertain universalJavaApplicationStub is the culprit, but it's the only common thread I can find in apps that exhibit this problem...your thoughts would be much appreciated.
Please tell us about your environment:
The text was updated successfully, but these errors were encountered: