0

I have a Java application that uses the Java sound API to record sound from the systems microphone. When run on macOS from the terminal, sound recording works as expected, but no sound is recorded when the app is packaged using install4j.

I am using Liberica JDK 17 as the runtime.

In Install4J, I use an entitlements file like this.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
    "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.security.device.audio-input</key>
    <true/>
    <key>com.apple.security.device.microphone</key>
    <true/>
  </dict>
</plist>

When run from Terminal using java -jar, the app requests microphone access. When packaged and run via Install4, there is no request for a permission.

The app is properly signed / notarized with a certificate.

Any ideas what I might be missing?

Thanks!

2 Answers 2

0

An entitlements file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.device.audio-input</key>
    <true/>
</dict>

is enough for requesting microphone permissions. The OS will still ask for the specific permission the first time you start recording, though. If the question was declined, it will not be shown again.

To reset the microphone permission request on macOS so that the system will ask for microphone access again after it has been previously denied, you need to reset the app's permissions with

tccutil reset Microphone <bundle ID>

You can find the bundle ID in the Contents/Info.plist file in the application bundle, it is contained in the value of the CFBundleIdentifier key.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you @Ingo Kegel for the input. I have limited the entitlements to the single one you mentioned, re-built the installer, reset the apps permission, installed the app, tried to use the microphone - but no luck. This happens on a Macbook Pro with Sonoma. I found a couple of hints about editing the TCC database directly, but Sonoma does no longer seem to allow that. Anything else I could try?
Sorry, I have no more related information available.
0

I finally figured this out. The Info.plist file needs an entry like this, explaining why the app needs access to the microphone:

<key>NSMicrophoneUsageDescription</key>
<string>This app requires access to the microphone for recording audio.</string>

You can specify this in install4j in the "Launchers" section, open the relevant launcher and its settings, and under "macOS options" use "customize plist file" to add the lines above.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.