dustinkredmond / FXTrayIcon

Tray Icon implementation for JavaFX applications. Say goodbye to using AWT's SystemTray icon, instead use a JavaFX Tray Icon.
MIT License
327 stars 26 forks source link

FXtrayIcon error when used it with springboot fx application #24

Closed BugsBountyHunter closed 2 years ago

BugsBountyHunter commented 2 years ago

When I'm using FXTrayIcon with JavaFX application that's work fine but now I need to run my project as spring-boot fx project I follow instructions here to run the spring-boot project as FX project https://blog.jetbrains.com/idea/2019/11/tutorial-reactive-spring-boot-a-javafx-spring-boot-application/

but when I used FXTrayIcon get me this exception message

Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
    at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: java.awt.HeadlessException
    at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:165)
    at java.desktop/java.awt.MenuComponent.<init>(MenuComponent.java:181)
    at java.desktop/java.awt.MenuItem.<init>(MenuItem.java:224)
    at java.desktop/java.awt.MenuItem.<init>(MenuItem.java:208)
    at java.desktop/java.awt.Menu.<init>(Menu.java:163)
    at java.desktop/java.awt.Menu.<init>(Menu.java:144)
    at java.desktop/java.awt.PopupMenu.<init>(PopupMenu.java:88)
    at java.desktop/java.awt.PopupMenu.<init>(PopupMenu.java:75)
    at com.dustinredmond.fxtrayicon.FXTrayIcon.<init>(FXTrayIcon.java:885)
    at com.dustinredmond.fxtrayicon.FXTrayIcon.<init>(FXTrayIcon.java:84)
    at com.dustinredmond.fxtrayicon.FXTrayIcon$Builder.<init>(FXTrayIcon.java:153)
    at com.ahmedsr.alphasyncui.AlphaSyncApplication.start(AlphaSyncApplication.java:29)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run$$$capture(InvokeLaterDispatcher.java:96)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
    ... 1 more

I ask about what's capabilities to integrate fxtrayicon with spring-boot-fx

EasyG0ing1 commented 2 years ago

@DEV-A7med

Hi,

I found this topic on StackOverflow, and the first answer mentions a need to set a java.awt.headless option in your SpringBoot project ... take a look at that post and see if you can work the solution into your project.

This post might also be of help.

Mike

dustinkredmond commented 2 years ago

@DEV-A7med try calling Java with the below option. This issue is due to Spring setting this option within the framework since Spring is typically meant to be run in a headless environment (think web server). This isn't an issue specific to FXTrayIcon, but I will leave the issue open in case you are able to post how to resolve it and help others if they choose to use a setup similar to yours.

-Djava.awt.headless=false
BugsBountyHunter commented 2 years ago

Thank you for helping @EasyG0ing1, @dustinkredmond, Now I create a new repo with two branches:

Now feel free if you need to add my sample to your sample code to help others

JavaFXWithSpringboot

EasyG0ing1 commented 2 years ago

Springboot... I looked at that once ... then I didn't ... I've been perhaps putting off the inevitable.