DEV Community

Cover image for JavaDoc WTF 4MB of Fonts JDK 23+
Davor Hrg
Davor Hrg

Posted on

JavaDoc WTF 4MB of Fonts JDK 23+

I was publishing two small packages to maven central and saw that they added usage tracking. I clicked and noticed 8MB number that should not be caused by 2 tiny packages, it was supposed to be kilobytes.

What happened wass that starting in JDK 23, the JDK javadoc tool began embedding default DejaVu web font files (~4 MB) into generated API documentation. The maven-javadoc-plugin passes the JDK's --no-fonts flag to disable this.

Option 1: Plugin Configuration

To disable copying web fonts across builds, set <disableNoFonts>false</disableNoFonts> (or explicitly pass additional arguments if running older toolchains) in your pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.11.3</version>
    <configuration>
        <!-- Disables font inclusion in JDK 23+ -->
        <additionalOptions>
            <additionalOption>--no-fonts</additionalOption>
        </additionalOptions>
    </configuration>
</plugin>

Enter fullscreen mode Exit fullscreen mode

Option 2: Property Switch or Maven Property

You can also control this property directly via the Maven property or command-line flag without modifying your execution configuration:

mvn clean javadoc:javadoc -Dmaven.javadoc.disableNoFonts=true

Enter fullscreen mode Exit fullscreen mode

JDK Compatibility Note: The --no-fonts option was introduced in JDK 23. If you use JDK 21 or earlier, explicitly passing --no-fonts will cause the JDK javadoc executable to throw an unrecognized option error.

Top comments (0)