简体   繁体   中英

Java Mac App Hiding Dock Icon

I recently wrote a small Java application with Eclipse and packaged the exported Runnable Jar using Apple's Jar Bundler. Everything works great, except my plist keys for hiding the application icon in the dock. I have tried previous plist keys I have used before to hide my dock icon, but they are not working. I run my app, the icon shows up in the dock and sits there bouncing for a while, then it stops bouncing and just sits there. I don't want the Dock icon shown, and I don't want a system tray icon. I am just needing my app to run in the background.

Keys I have tried and had no luck.

apple.awt.UIElement true

and

Application is agent (UIElement) set to True/Yes in Plist Editor

UPDATE: Here is my plist. My app still bounces in the dock. If I let it sit for a while it will eventually start to work.

<?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>LSUIElement</key>
    <string>1</string>
    <key>CFBundleName</key>
    <string>My App</string>
    <key>CFBundleIdentifier</key>
    <string>org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader</string>
    <key>CFBundleVersion</key>
    <string>100.0</string>
    <key>CFBundleAllowMixedLocalizations</key>
    <string>true</string>
    <key>CFBundleExecutable</key>
    <string>JavaApplicationStub</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleGetInfoString</key>
    <string>My App</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleIconFile</key>
    <string>icon.icns</string>
    <key>Java</key>
    <dict>
        <key>WorkingDirectory</key>
        <string>$APP_PACKAGE/Contents/Resources/Java</string>
        <key>MainClass</key>
        <string>org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader</string>
        <key>JVMVersion</key>
        <string>1.6+</string>
        <key>ClassPath</key>
        <string>$JAVAROOT/myapp.jar</string>
        <key>Properties</key>
        <dict/>
    </dict>
</dict>
</plist>

UPDATE 2: When I run my java application using terminal command sudo open /Applications/MyJava.app it runs fine. If I run my app normally, and let it bounce on the dock for a while it will eventually run. I would prefer not prompting the user for credentials to just run my simple app.

In your plist: java -Djava.awt.headless=true

or

in your code: System.setProperty("java.awt.headless", "true");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM