gpt4 book ai didi

java - ApachePoi 在 OpenJdk 1.8.0_121 上因字体错误而失败 在 Oracle Jre 上没问题

转载 作者:行者123 更新时间:2023-12-05 05:21:19 27 4
gpt4 key购买 nike

错误发生在初始化 org.apache.poi.ss.usermodel.Sheet 期间我可以修复此问题以防止 Linux 上的 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 java.awt.Font.getFont2D(Font.java:491)
at java.awt.Font.canDisplayUpTo(Font.java:2060)
at java.awt.font.TextLayout.singleFont(TextLayout.java:470)
at java.awt.font.TextLayout.<init>(TextLayout.java:531)
at org.apache.poi.ss.util.SheetUtil.getDefaultCharWidth(SheetUtil.java:275)
at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.<init>(AutoSizeColumnTracker.java:117)
at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:79)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:656)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:677)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:83)
at com.jthink.songkong.reports.spreadsheet.Worksheet.<init>(Worksheet.java:24)

更新

根据评论,在 lib 中找不到字体文件

[root@N1-ZS10 库]# ls -l

total 70948
drwxrwxr-x 4 root root 4096 Mar 29 15:09 aarch32
drwxrwxr-x 2 root root 4096 Mar 29 11:28 applet
-rw-rw-r-- 1 root root 2375 Mar 29 11:28 calendars.properties
-rw-rw-r-- 1 root root 3135391 Mar 29 11:28 charsets.jar
-rw-rw-r-- 1 root root 84311 Mar 29 11:28 classlist
drwxrwxr-x 2 root root 4096 Mar 29 15:09 cmm
-rw-rw-r-- 1 root root 5916 Mar 29 11:28 content-types.properties
-r--r--r-- 1 root root 4122 Mar 29 11:28 currency.data
drwxrwxr-x 2 root root 4096 Mar 29 15:09 ext
-rw-rw-r-- 1 root root 3901 Mar 29 11:28 flavormap.properties
-rw-rw-r-- 1 root root 14959 Mar 29 11:28 hijrah-config-umalqura.properties
drwxrwxr-x 3 root root 4096 Mar 29 15:08 images
-rw-rw-r-- 1 root root 95642 Mar 29 11:28 jce.jar
-rwxrwxr-x 1 root root 15917 Mar 29 11:28 jexec
-rw-rw-r-- 1 root root 647046 Mar 29 11:28 jsse.jar
-rw-rw-r-- 1 root root 4226 Mar 29 11:28 jvm.hprof.txt
-rw-rw-r-- 1 root root 2455 Mar 29 11:28 logging.properties
drwxrwxr-x 2 root root 4096 Mar 29 15:09 management
-rw-rw-r-- 1 root root 381 Mar 29 11:28 management-agent.jar
-rw-rw-r-- 1 root root 1922 Mar 29 11:28 meta-index
-rw-rw-r-- 1 root root 4464 Mar 29 11:28 net.properties
-rw-rw-r-- 1 root root 3793 Mar 29 11:28 psfont.properties.ja
-rw-rw-r-- 1 root root 11390 Mar 29 11:28 psfontj2d.properties
-rw-rw-r-- 1 root root 3509545 Mar 29 11:28 resources.jar
-rw-rw-r-- 1 root root 64833198 Mar 29 11:28 rt.jar
drwxrwxr-x 2 root root 4096 Mar 29 15:08 security
-rw-rw-r-- 1 root root 1210 Mar 29 11:28 sound.properties
-rw-rw-r-- 1 root root 104311 Mar 29 11:28 tzdb.dat

最佳答案

为了完整起见,我在这里添加 Paul Taylor 的回答:

Openjdk depends on system fonts of which i had none installed, but I found that creating a fonts folder in the jre's lib folder and just copyig some fonts into it fixed the problem

see here: stackoverflow.com/questions/43144517/…

关于java - ApachePoi 在 OpenJdk 1.8.0_121 上因字体错误而失败 在 Oracle Jre 上没问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43096782/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com