praj-foss / swing-graalvm-demo

Swing demo app compiled with GraalVM native-image
https://www.praj.in/posts/2021/compiling-swing-apps-ahead-of-time/
The Unlicense
20 stars 5 forks source link

java.lang.Error: java.home property not set #5

Open ctoabidmaqbool opened 3 months ago

ctoabidmaqbool commented 3 months ago

On windows, I first try to do run agent, and then build the native-image and it's saying above errro:

D:\NetBeansProjects\BuildApps\swing-graalvm-demo>demo.exe
java.lang.Error: java.home property not set
        at java.desktop@22.0.2/sun.awt.FontConfiguration.findFontConfigFile(FontConfiguration.java:180)
        at java.desktop@22.0.2/sun.awt.FontConfiguration.<init>(FontConfiguration.java:97)
        at java.desktop@22.0.2/sun.awt.windows.WFontConfiguration.<init>(WFontConfiguration.java:41)
        at java.desktop@22.0.2/sun.awt.Win32FontManager.createFontConfiguration(Win32FontManager.java:175)
        at java.desktop@22.0.2/sun.font.SunFontManager$2.run(SunFontManager.java:352)
        at java.desktop@22.0.2/sun.font.SunFontManager$2.run(SunFontManager.java:309)
        at java.base@22.0.2/java.security.AccessController.executePrivileged(AccessController.java:128)
        at java.base@22.0.2/java.security.AccessController.doPrivileged(AccessController.java:319)
        at java.desktop@22.0.2/sun.font.SunFontManager.<init>(SunFontManager.java:309)
        at java.desktop@22.0.2/sun.awt.Win32FontManager.<init>(Win32FontManager.java:83)
        at java.desktop@22.0.2/sun.font.PlatformFontInfo.createFontManager(PlatformFontInfo.java:37)
        at java.desktop@22.0.2/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:51)
        at java.desktop@22.0.2/java.awt.Font.getFont2D(Font.java:526)
        at java.desktop@22.0.2/java.awt.Font.getFamily(Font.java:1433)
        at java.desktop@22.0.2/java.awt.Font.getFamily_NoClientCode(Font.java:1407)
        at java.desktop@22.0.2/java.awt.Font.getFamily(Font.java:1399)
        at com.formdev.flatlaf.FlatLaf.initFonts(FlatLaf.java:465)
        at com.formdev.flatlaf.FlatLaf.getDefaults(FlatLaf.java:399)
        at java.desktop@22.0.2/javax.swing.UIManager.setLookAndFeel(UIManager.java:591)
        at java.desktop@22.0.2/javax.swing.UIManager.setLookAndFeel(UIManager.java:637)
        at com.formdev.flatlaf.demo.DemoPrefs.initLaf(DemoPrefs.java:83)
        at com.formdev.flatlaf.demo.FlatLafDemo.lambda$main$0(FlatLafDemo.java:54)
        at java.desktop@22.0.2/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
        at java.desktop@22.0.2/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
        at java.desktop@22.0.2/java.awt.EventQueue$4.run(EventQueue.java:720)
        at java.desktop@22.0.2/java.awt.EventQueue$4.run(EventQueue.java:714)
        at java.base@22.0.2/java.security.AccessController.executePrivileged(AccessController.java:128)
        at java.base@22.0.2/java.security.AccessController.doPrivileged(AccessController.java:400)
        at java.base@22.0.2/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
        at java.desktop@22.0.2/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:853)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:829)
Exception in thread "AWT-EventQueue-0" java.lang.Error: java.home property not set
        at java.desktop@22.0.2/sun.awt.FontConfiguration.findFontConfigFile(FontConfiguration.java:180)
        at java.desktop@22.0.2/sun.awt.FontConfiguration.<init>(FontConfiguration.java:97)
        at java.desktop@22.0.2/sun.awt.windows.WFontConfiguration.<init>(WFontConfiguration.java:41)
        at java.desktop@22.0.2/sun.awt.Win32FontManager.createFontConfiguration(Win32FontManager.java:175)
        at java.desktop@22.0.2/sun.font.SunFontManager$2.run(SunFontManager.java:352)
        at java.desktop@22.0.2/sun.font.SunFontManager$2.run(SunFontManager.java:309)
        at java.base@22.0.2/java.security.AccessController.executePrivileged(AccessController.java:128)
        at java.base@22.0.2/java.security.AccessController.doPrivileged(AccessController.java:319)
        at java.desktop@22.0.2/sun.font.SunFontManager.<init>(SunFontManager.java:309)
        at java.desktop@22.0.2/sun.awt.Win32FontManager.<init>(Win32FontManager.java:83)
        at java.desktop@22.0.2/sun.font.PlatformFontInfo.createFontManager(PlatformFontInfo.java:37)
        at java.desktop@22.0.2/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:51)
        at java.desktop@22.0.2/java.awt.Font.getFont2D(Font.java:526)
        at java.desktop@22.0.2/java.awt.Font.getFamily(Font.java:1433)
        at java.desktop@22.0.2/java.awt.Font.getFamily_NoClientCode(Font.java:1407)
        at java.desktop@22.0.2/java.awt.Font.getFamily(Font.java:1399)
        at com.formdev.flatlaf.FlatLaf.initFonts(FlatLaf.java:465)
        at com.formdev.flatlaf.FlatLaf.getDefaults(FlatLaf.java:399)
        at java.desktop@22.0.2/javax.swing.UIManager.setLookAndFeel(UIManager.java:591)
        at com.formdev.flatlaf.FlatLaf.install(FlatLaf.java:103)
        at com.formdev.flatlaf.FlatLightLaf.install(FlatLightLaf.java:38)
        at com.formdev.flatlaf.demo.DemoPrefs.initLaf(DemoPrefs.java:89)
        at com.formdev.flatlaf.demo.FlatLafDemo.lambda$main$0(FlatLafDemo.java:54)
        at java.desktop@22.0.2/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
        at java.desktop@22.0.2/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
        at java.desktop@22.0.2/java.awt.EventQueue$4.run(EventQueue.java:720)
        at java.desktop@22.0.2/java.awt.EventQueue$4.run(EventQueue.java:714)
        at java.base@22.0.2/java.security.AccessController.executePrivileged(AccessController.java:128)
        at java.base@22.0.2/java.security.AccessController.doPrivileged(AccessController.java:400)
        at java.base@22.0.2/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
        at java.desktop@22.0.2/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop@22.0.2/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:853)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:829)
ctoabidmaqbool commented 3 months ago
java -agentlib:native-image-agent=config-output-dir=config -jar flatlaf-demo.jar

and

java -jar flatlaf-demo.jar

is working fine!