dorkbox / SystemTray

Cross-platform SystemTray support for Swing/AWT, macOS, GtkStatusIcon, and AppIndicator on Java 8+
Other
446 stars 58 forks source link

Is there any GraalVM native-image support availabe? #218

Open ctoabidmaqbool opened 3 months ago

ctoabidmaqbool commented 3 months ago

Hi all! It looks like instrusting project!

Can this project be secessfully work on GraalVM native-image project!

Actually I am instrusted in using JavaFx and want to put put my app on System Tray icon (Windows currently). Also there is a new Java technology called GraalVM and it have a nice feature Native Image.

I am wondring if it's can be used in Graalvm native-image.

Note: GraalVM native-image does't support 100% AWT/Swing apps!

ctoabidmaqbool commented 3 months ago

Native compiling, and link is done secessfully!

gradlew :SystemTray:clean :SystemTray:nativeBuild

process-compile-1723996447710.log process-link-1723996449634.log client-debug0.log client-debug0.log.1.txt

After native building I try to native run but still errors e.g. Caused by: java.lang.UnsatisfiedLinkError: no awt in java.library.path:

gradlew :SystemTray:nativeRun

client-debug0.log.2.txt

I manuely copy these libs to folder D:\JavaFx-Android\gluon-samples-gradle\SystemTray\build\gluonfx\x86_64-windows awt.dll, fontmanager.dll, freetype.dll, java.dll, jvm.dll

but still error:

client-debug0.log.3.txt

Note: before running native compile I also run gradlew :SystemTray:nativeRunAgent

Simple gradlew :SystemTray:run and gradlew :SystemTray:nativeRunAgent works correctly!

ctoabidmaqbool commented 3 months ago

There are couple of issues alrady. https://github.com/gluonhq/gluonfx-maven-plugin/issues/505 https://github.com/oracle/graal/issues/8273 https://github.com/oracle/graal/issues/3084

ctoabidmaqbool commented 3 months ago

Last error I am facing Caused by: java.lang.Error: java.home property not set:

[Mon Aug 19 09:36:33 PKT 2024][INFO] ==================== RUN TASK ====================
[Mon Aug 19 09:36:33 PKT 2024][FINE] PB Command for run until end: D:\JavaFx-Android\gluon-samples-gradle\SystemTray\build\gluonfx\x86_64-windows\SystemTray.exe
[Mon Aug 19 09:36:33 PKT 2024][FINE] Start process run until end...
[Mon Aug 19 09:36:33 PKT 2024][INFO] [SUB] Aug 19, 2024 9:36:33 AM com.sun.javafx.application.PlatformImpl startup
[Mon Aug 19 09:36:33 PKT 2024][INFO] [SUB] WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @41b13f3d'
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB] Aug 19, 2024 9:36:34 AM dorkbox.systemTray.SystemTray get
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB] SEVERE: Unable to create tray type: '_WindowsNativeTray'
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB] java.lang.reflect.InvocationTargetException
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at dorkbox.systemTray.SystemTray.get(SystemTray.java:799)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at dorkbox.TestTrayJavaFX.doJavaFxStuff(TestTrayJavaFX.java:119)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at dorkbox.TestTrayJavaFX$MyApplication.start(TestTrayJavaFX.java:74)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:839)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.security.AccessController.executePrivileged(AccessController.java:128)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.security.AccessController.doPrivileged(AccessController.java:400)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.lang.Thread.runWith(Thread.java:1583)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.lang.Thread.run(Thread.java:1570)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:853)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:829)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB] Caused by: java.lang.Error: java.home property not set
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.awt.FontConfiguration.findFontConfigFile(FontConfiguration.java:180)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.awt.FontConfiguration.<init>(FontConfiguration.java:97)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.awt.windows.WFontConfiguration.<init>(WFontConfiguration.java:41)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.awt.Win32FontManager.createFontConfiguration(Win32FontManager.java:175)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.font.SunFontManager$2.run(SunFontManager.java:352)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.font.SunFontManager$2.run(SunFontManager.java:309)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.security.AccessController.executePrivileged(AccessController.java:128)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.security.AccessController.doPrivileged(AccessController.java:319)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.font.SunFontManager.<init>(SunFontManager.java:309)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.awt.Win32FontManager.<init>(Win32FontManager.java:83)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.font.PlatformFontInfo.createFontManager(PlatformFontInfo.java:37)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:51)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/java.awt.Font.getFont2D(Font.java:526)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/java.awt.Font$FontAccessImpl.getFont2D(Font.java:265)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.font.FontUtilities.getFont2D(FontUtilities.java:151)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.font.StandardGlyphVector.initFontData(StandardGlyphVector.java:1110)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.font.StandardGlyphVector.init(StandardGlyphVector.java:1099)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/sun.font.StandardGlyphVector.<init>(StandardGlyphVector.java:163)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at java.desktop@22.0.2/java.awt.Font.createGlyphVector(Font.java:2745)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at dorkbox.util.FontUtil.getFontHeight(FontUtil.kt:162)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at dorkbox.systemTray.ui.swing.SwingMenuItemCheckbox.createCheckedIcon(SwingMenuItemCheckbox.java:57)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  at dorkbox.systemTray.ui.swing._WindowsNativeTray.<init>(_WindowsNativeTray.java:88)
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB]  ... 18 more
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB] 
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB] Exception in Application start method
[Mon Aug 19 09:36:34 PKT 2024][INFO] [SUB] Exception in Application stop method
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB] Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:893)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.lang.Thread.runWith(Thread.java:1583)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.lang.Thread.run(Thread.java:1570)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:853)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:829)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB] Caused by: java.lang.RuntimeException: Unable to load SystemTray!
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at dorkbox.TestTrayJavaFX.doJavaFxStuff(TestTrayJavaFX.java:121)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at dorkbox.TestTrayJavaFX$MyApplication.start(TestTrayJavaFX.java:74)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:839)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.security.AccessController.executePrivileged(AccessController.java:128)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at java.base@22.0.2/java.security.AccessController.doPrivileged(AccessController.java:400)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185)
[Mon Aug 19 09:36:35 PKT 2024][INFO] [SUB]  ... 4 more
[Mon Aug 19 09:36:35 PKT 2024][FINE] Result for run until end: 0
ctoabidmaqbool commented 3 months ago

https://github.com/oracle/graal/issues/4344