Java on Debian: Probable fatal error: No fonts found
I want to run Tomcat on Debian 5 Minimal开发者_JAVA技巧. So I don't need a gui for my OS, it's just a pure Tomcat-Server.
Which packages do I need for my JVM to use Fonts in my applications? Im drawing texts in Graphics2D and am creating PDF-Files in my Java-Project.
I had similar problem on CentOS, after crunching for a solution..
I solved this problem by installing fonts like follows:
sudo yum install bitmap*
sudo yum install dejavu-lgc*
sudo yum install bitstream-vera*
Graphics2D and anything in the java.awt.*
or java.swing.*
packages require a GUI to do its drawing.
This is a problem on most headless servers. You have two options, and try them in this order:
Use the system property "java.awt.headless" and set that to "true"
java -Djava.awt.headless=true
orSystem.setProperty("java.awt.headless", "true");
Install the XWindows Virtual Frame Buffer (xvfb) on your server. This keeps the server headless, but provides the XWindows primitives needed to draw on a virtual screen. It is far from optimized (no graphics acceleration), but it will allow your system to work again.
The java.awt.headless
option was introduced with Java 1.4. See: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/
In the event that does not work, install the XVFB package and configure it to create a virtual frame buffer large enough to do your drawing.
I fixed this by installing some fonts (under Ubuntu) by:
apt-get install msttcorefonts
They should be installed in /usr/share/fonts/truetype/
.
Dont forget to restart Tomcat if you use it.
None of the answers above worked for me on a Amazon Linux AMI with OpenJDK 1.6.0_20. However this worked:
sudo yum install dejavu*
ln -s /usr/share/fonts/dejavu /usr/share/fonts/dejavu-lgc
The first line installs some default fonts, and the second ensures that Java finds them. More at http://brandon.fuller.name/archives/2011/09/12/00.05.15/
I encountered this issue with Atlassian Bamboo recently. On Scientific Linux all that I was required to do was:
sudo yum install dejavu*
(Unlike mkvalsvik I did not need to make a symlink).
For me, this has solved it: https://bugzilla.redhat.com/show_bug.cgi?id=708201 Basically the 'java' package did not depend on 'fontconfig', which had to be manually installed.
精彩评论