0

I want to run Tomcat on Debian 5 Minimal. 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.

4
  • your question is which api to use to create PDF or how to make debian use your font in your code?
    – jmj
    Dec 14, 2010 at 11:59
  • The second one. The application itself works perfectly on systems which do have a windowManager installed. So I think my debian-installation is missing some packages
    – Sven
    Dec 14, 2010 at 12:13
  • Probably. the fonts used by java can be found in the jre/lib/fontconfig.properties which is usually a softlink to the actual font file but is a place for you to start. Dec 14, 2010 at 12:40
  • Thanks for your help! I dont know what the problem really was, but apt-get upgrade helped..
    – Sven
    Dec 14, 2010 at 13:08

6 Answers 6

3

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:

  1. Use the system property "java.awt.headless" and set that to "true" java -Djava.awt.headless=true or System.setProperty("java.awt.headless", "true");

  2. 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.

3

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*
1

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.

1

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/

1

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).

0

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.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.