B4J Question How to hide Java icon from Dock in MacOS

Status
Not open for further replies.

Markos

Active Member
Licensed User
Longtime User
Hi All,

I researched for hours and still no solution how to hide or remove the Java icon from appearing when running a Java based App on the mac..

There are several solutions proposed online none of which works for me I'm using JDK11.x on Catalina Mac OSX

The most common proposed solution is to set the system property apple.awt.UIElement=true

I've tried it via a VM argument as java -jar -Dapple.awt.UIElement=true javaname.jar (and alternativelyapple.awt.UIElement="true")
also

SetSystemProperty("apple.awt.UIElement", "true") in B4J at the beginning of AppStart and still the Java appears in the Dock.

Other suggestions to try apple.awt.headless=true or java.awt.headless=true with no luck.

Has anyone found a solution for this challenge?

More Info:

My App uses JavaFX components and it seems JavaFX currently doesnt support Dock Icon Less capability. Having said that is their a work around I can do in either B4J code or in the scripts calling the Jar to not have the Java Coffee icon appear in the dock alongside my running App Icon.
 
Last edited:

Markos

Active Member
Licensed User
Longtime User
Hi Erel

Below seems to do the trick but relies on inclusion in the main.java block where it calls the javafx application.

B4X:
public class AppAwt {
    public static void main(String[] args) throws Exception {
        System.setProperty("apple.awt.UIElement", "true");
        java.awt.Toolkit.getDefaultToolkit();
        TestTrayJavaFX.main(args);
    }
}

I think and will stand corrected by you as needed, the relevant lines to include are

B4X:
System.setProperty("apple.awt.UIElement", "true");
        java.awt.Toolkit.getDefaultToolkit();

If you can include in a sample javafx app built to jar and I will test. If works perhaps we can be empowered to alter or include code in the main block of main.java inside B4J.
 
Last edited:
Upvote 0

Markos

Active Member
Licensed User
Longtime User
Both at Java command and within the B4J appstart code module it does not work. It seems as stated online it is preferred within the main.java to truly achive setting prior to javafx app start
 
Upvote 0

Markos

Active Member
Licensed User
Longtime User
This appends the menu system from the preferred Application header to the Java menu but does not hide or remove the Java menu or Java/Coffee Dock
 
Upvote 0

Markos

Active Member
Licensed User
Longtime User
It will solve the issue where your app name doesn't appear on the title.
Thanks Erel,

That did correct an issue I didnt identify and a nice compliant feature for MacOSX user standards.

However That's not my initial store related issue. My issue is to make the App dockless for the Java component/icon. My App Dock icon and Menu is fine, the additional Java Menu and Docked icon is the issue.

Below shows the suggestion of how to modify the main.java. However the setting using -Dapple.awt.UIElement=true is not as reliable

https://stackoverflow.com/questions...up-icon-from-appearing-in-the-dock-on-mac-osx

If this suggestion is illogical then I will have to wait until someone finds a solution online and shares it

Thanks for trying, perhaps a few days from now a solution may come to you.
 
Last edited:
Upvote 0

Markos

Active Member
Licensed User
Longtime User
I don't know if the below image supports my theory. When applying the setproperty within B4J Appstart code and running the run.command

headless.jpg
 
Upvote 0

Markos

Active Member
Licensed User
Longtime User
Dear Erel,

I have tried all methods online, be it swing, awt libraries and they all are useless for Javafx App. It may be attributed to a shortcoming of the the Jdk11+ that we have to live with. The only aspect I couldnt try and that may be a dead end to and that is to make amendments to the main.java to ensure we apply prior to javafx running, but that is only in your control and discretion.

What I did as a work around is to hide the App bundle dock and menu and rename the java to my Program name and use -Xdock:icon=iconname to apply my program icon to replace the java coffee icon. There is still the issue of the class name showing up in the sub menu items next to Hide & Quit. I will submit to Mac Apple and see if they will permit despite that discrepency in naming convention
 
Upvote 0

Markos

Active Member
Licensed User
Longtime User
An update.

The class name appearing in the sub menu item list is not accepted by Apple. Do we have an alternate solution for -Xdock:name=appname for java command as it is not working and no programmatic solution exists as far as I can see and possibly even if we had access to main.java it may be iffy at best.
 
Upvote 0
Status
Not open for further replies.
Top