OpenJDK fails when no fonts are installed

Solution Verified - Updated -

Issue

  • Application fails to run on OpenJDK, with below error on Linux.
Exception in thread "main" java.lang.NullPointerException
    at sun.awt.X11FontManager.getDefaultPlatformFont(X11FontManager.java:779)
    at sun.font.SunFontManager$2.run(SunFontManager.java:432)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.font.SunFontManager.<init>(SunFontManager.java:375)
    at sun.awt.X11FontManager.<init>(X11FontManager.java:32)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at java.lang.Class.newInstance0(Class.java:372)
    at java.lang.Class.newInstance(Class.java:325)
    at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
    at java.awt.Font.<init>(Font.java:613)
    at java.awt.Font.createFont(Font.java:1023)
    at Test.main(Test.java:7)
  • java.lang.NullPointerException error in Linux while launching Java application with OpenJDK:
java.lang.NullPointerException 
 at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
 at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219)
 at sun.awt.FontConfiguration.init(FontConfiguration.java:107)
 at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:774)
 at sun.font.SunFontManager$2.run(SunFontManager.java:431)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.font.SunFontManager.<init>(SunFontManager.java:376)
 at sun.awt.FcFontManager.<init>(FcFontManager.java:35)
 at sun.awt.X11FontManager.<init>(X11FontManager.java:57)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
 at java.lang.Class.newInstance(Class.java:442)
 at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
 at sun.font.SunFontManager.getInstance(SunFontManager.java:250)
 at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:264)
 at sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1113)
 ....
  • Exception in net.sf.jasperreports.engine.util.JRStyledTextParser:
ERROR [stderr] (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#654b4bf0-1995) Exception in thread "org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#654b4bf0-1995" java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser

Environment

  • Red Hat Enterprise Linux (RHEL)
    • 6.x
    • 7.x
  • Linux
  • OpenJDK
    • 7
    • 8

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content