How to install font on linux

6.1k Views Asked by At

I am using windows os, So there is no issue with Font(java.awt) class object creation. but my testing environment is on linux. So on that I am getting NULL POINTER exception.

Cannot load from short array because "sun.awt.FontConfiguration.head" is null

After seacrhing I found that there should be fonts folder in usr/share directory on linux. So someone can please suggest. Do I have to just copy fonts to that directory or there is other way to intsall?

1

There are 1 best solutions below

1
user3682640 On BEST ANSWER

For my configuration (java.18/Spring Boot/jib/Docker/ubuntu) I've used this these commands for resolving the issue:

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN apt-get update -y
RUN apt-get install -y apt-utils    --no-install-recommends
RUN apt-get install -y libfreetype6 --no-install-recommends
RUN apt-get install -y fontconfig   --no-install-recommends
RUN apt-get install -y fonts-dejavu --no-install-recommends