I use Apache POI to write out a spreadsheet. The problematic line is where I invoke Sheet#autoSizeColumn(int column)
. If I run it on a unix shell with no graphical environment, the following exception appears:
Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: /usr/pkg/java/openjdk7/jre/lib/amd64/xawt/libmawt.so: Shared object "libXext.so.7" not found
According to apache's quick guide there is a property which should be set to signalize headless environment, so I try the following call:
java -jar -Xmx200m -Djava.awt.headless=true myJar.jar
But I get then another exception for the same line:
Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: /usr/pkg/java/openjdk7/jre/lib/amd64/libfontmanager.so: Shared object "libfreetype.so.7" not found
The above apache guide also says "I should ensure that the fonts I use in your workbook are available to Java". I really don't use any specific fonts, the one and only thing I do with fonts is
XSSFFont boldFont = (XSSFFont) wb.createFont();
boldFont.setBold(true);
titleRowStyle.setFont(boldFont);
The unix shell runs
openjdk version "1.7.0-internal"
OpenJDK Runtime Environment (build 1.7.0-internal-pkgsrc_2015_01_06_05_56-b00)
OpenJDK 64-Bit Server VM (build 24.71-b01, mixed mode)
and
NetBSD *** 6.1.5 NetBSD 6.1.5 (jajo) #1: Sun Jun 21 09:13:03 UTC 2015 spaj@***:/usr/src/sys/arch/amd64/compile/jajo amd64
Is it possible to fix this issue?
I found an older library version in the system:
bash-4.3$ find /usr -name "libfreetype.*"
find: /usr/games/hide: Permission denied
/usr/pkg/lib/libfreetype.la
/usr/pkg/lib/libfreetype.a
/usr/pkg/lib/libfreetype.so
/usr/pkg/lib/libfreetype.so.6
/usr/pkg/lib/libfreetype.so.6.11.3
Then I created a symbolic link for the lastest available version as if it would be version 7:
ln -s /usr/pkg/lib/libfreetype.so.6.11.3 ~/tmp/lib/libfreetype.so.7
And start now my jar file with an environment variable:
LD_LIBRARY_PATH=~/tmp/lib java -jar -Xmx200m -Djava.awt.headless=true myJar.jar