I'm using openJDK 11.0.2 on ubuntu (docker image).
Code:
package test; import java.awt.*; import java.awt.image.BufferedImage; public class Main { public static void main(String[] args) { BufferedImage mapImage = new BufferedImage(128, 128, BufferedImage.TYPE_INT_RGB); Graphics2D canvas = mapImage.createGraphics(); canvas.drawString("test", 1, 1); } }
Error:
Exception in thread "main" java.lang.InternalError: java.lang.reflect.InvocationTargetException
at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFacto ry.java:86)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.FontManagerFactory.getInstance(FontManage rFactory.java:74)
at java.desktop/java.awt.Font.getFont2D(Font.java:497)
at java.desktop/java.awt.Font$FontAccessImpl.getFont2D(Font.java:2 37)
at java.desktop/sun.font.FontUtilities.getFont2D(FontUtilities.jav a:139)
at java.desktop/sun.java2d.SunGraphics2D.checkFontInfo(SunGraphics 2D.java:670)
at java.desktop/sun.java2d.SunGraphics2D.getFontInfo(SunGraphics2D .java:831)
at java.desktop/sun.java2d.pipe.GlyphListPipe.drawString(GlyphList Pipe.java:46)
at java.desktop/sun.java2d.pipe.ValidatePipe.drawString(ValidatePi pe.java:165)
at java.desktop/sun.java2d.SunGraphics2D.drawString(SunGraphics2D. java:2929)
at test.Main.main(Main.java:10)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl .newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl .newInstance(NativeConstructorAccessorImpl.java:62 )
at java.base/jdk.internal.reflect.DelegatingConstructorAccessor Impl.newInstance(DelegatingConstructorAccessorImpl .java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Construc tor.java:490)
at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFacto ry.java:84)
... 11 more
Caused by: java.lang.NullPointerException
at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfigura tion.java:1262)
at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontC onfiguration.java:225)
at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.j ava:107)
at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11 FontManager.java:719)
at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java: 367)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java :312)
at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35 )
at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java: 56)
... 16 more
Any help is greatly appreciated.