Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiled native-image crashes with java.lang.Error: java.home property not set #1

Closed
lyjia opened this issue Aug 25, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@lyjia
Copy link
Owner

lyjia commented Aug 25, 2023

PS G:\tom\src\java\NiceYtDlpGui> .\target\NiceYtDlpGui.exe
Exception in thread "main" java.lang.Error: java.home property not set
        at java.desktop@20.0.2/sun.awt.FontConfiguration.findFontConfigFile(FontConfiguration.java:180)
        at java.desktop@20.0.2/sun.awt.FontConfiguration.<init>(FontConfiguration.java:97)
        at java.desktop@20.0.2/sun.awt.windows.WFontConfiguration.<init>(WFontConfiguration.java:41)
        at java.desktop@20.0.2/sun.awt.Win32FontManager.createFontConfiguration(Win32FontManager.java:175)
        at java.desktop@20.0.2/sun.font.SunFontManager$2.run(SunFontManager.java:352)
        at java.desktop@20.0.2/sun.font.SunFontManager$2.run(SunFontManager.java:309)
        at java.base@20.0.2/java.security.AccessController.executePrivileged(AccessController.java:171)
        at java.base@20.0.2/java.security.AccessController.doPrivileged(AccessController.java:319)
        at java.desktop@20.0.2/sun.font.SunFontManager.<init>(SunFontManager.java:309)
        at java.desktop@20.0.2/sun.awt.Win32FontManager.<init>(Win32FontManager.java:83)
        at java.desktop@20.0.2/sun.font.PlatformFontInfo.createFontManager(PlatformFontInfo.java:37)
        at java.desktop@20.0.2/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:51)
        at java.desktop@20.0.2/java.awt.Font.getFont2D(Font.java:526)
        at java.desktop@20.0.2/java.awt.Font.getFamily(Font.java:1433)
        at java.desktop@20.0.2/java.awt.Font.getFamily_NoClientCode(Font.java:1407)
        at java.desktop@20.0.2/java.awt.Font.getFamily(Font.java:1399)
        at com.formdev.flatlaf.FlatLaf.initDefaultFont(FlatLaf.java:612)
        at com.formdev.flatlaf.FlatLaf.getDefaults(FlatLaf.java:487)
        at java.desktop@20.0.2/javax.swing.UIManager.setLookAndFeel(UIManager.java:592)
        at us.lyjia.NiceYtDlpGui.Main.main(Main.java:12)

Compiled native image crashes with above exception because of some Swing stuff hasnt been ported to the GraalVM compiler yet.

Tested on Windows. Not sure about other platforms.

Relevant github issues:

@lyjia lyjia self-assigned this Aug 25, 2023
@lyjia lyjia added the bug Something isn't working label Aug 25, 2023
lyjia pushed a commit that referenced this issue Aug 25, 2023
@lyjia
Copy link
Owner Author

lyjia commented Aug 26, 2023

fixed in 80b80c8

java.home is not set on native-image executables because they are standalone. As a workaround we set the working dir to java.home and copy some dependencies/resources into it so they can be found.

However this now opens the door for #2

@lyjia lyjia closed this as completed Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant