简体   繁体   English

Java Mac App隐藏底座图标

[英]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. 我最近用Eclipse编写了一个小型Java应用程序,并使用Apple的Jar Bundler打包了导出的Runnable Jar。 Everything works great, except my plist keys for hiding the application icon in the dock. 一切正常,除了我的用于在扩展坞中隐藏应用程序图标的plist键。 I have tried previous plist keys I have used before to hide my dock icon, but they are not working. 我尝试了以前使用过的先前的plist键来隐藏我的停靠图标,但是它们不起作用。 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. 我不希望显示Dock图标,也不希望系统托盘图标。 I am just needing my app to run in the background. 我只需要我的应用程序在后台运行即可。

Keys I have tried and had no luck. 我尝试过的钥匙,没有运气。

apple.awt.UIElement true apple.awt.UIElement是

and

Application is agent (UIElement) set to True/Yes in Plist Editor 在Plist编辑器中将应用程序代理(UIElement)设置为True / Yes

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. 更新2:当我使用终端命令sudo open /Applications/MyJava.app运行我的Java应用程序时,它运行良好。 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 在您的plist中: java -Djava.awt.headless=true

or 要么

in your code: System.setProperty("java.awt.headless", "true"); 在您的代码中: System.setProperty("java.awt.headless", "true");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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