Debian 上的 Java:可能的致命错误:未找到字体
我想在 Debian 5 Minimal 上运行 Tomcat.所以我的操作系统不需要 gui,它只是一个纯粹的 Tomcat 服务器.
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.
我的 JVM 需要哪些软件包才能在我的应用程序中使用字体?我在 Graphics2D 中绘制文本并在我的 Java 项目中创建 PDF 文件.
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.
推荐答案
Graphics2D 和 java.awt.*
或 java.swing.*
包中的任何内容都需要GUI 来做它的绘图.
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:
使用系统属性java.awt.headless"并将其设置为true"
java -Djava.awt.headless=true
或System.setProperty("java.awt.headless", "true");
在您的服务器上安装 XWindows 虚拟帧缓冲区 (xvfb).这使服务器保持无头,但提供了在虚拟屏幕上绘图所需的 XWindows 原语.它远未优化(无图形加速),但它可以让您的系统再次工作.
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.
java.awt.headless
选项是在 Java 1.4 中引入的.请参阅:http://java.sun.com/developer/technicalArticles/J2SE/桌面/无头/
The java.awt.headless
option was introduced with Java 1.4. See: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/
如果不起作用,请安装 XVFB 包并将其配置为创建一个足够大的虚拟帧缓冲区来进行绘图.
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.
相关文章