移植使用AWT和Swing绘制电影服务器端Java应用程序 [英] Porting a Java app that uses AWT and Swing for drawing movies to the server-side
问题描述
我与一些code,它的动画输出写入使用AWT和Swing功能的桌面工作。它使用绘制2D图形和字体呈现的文字。
I am working with some code that writes animated output to the desktop using AWT and Swing features. It draws using 2D graphics and renders text in fonts.
这code可以使用Java媒体框架保存animationto电影文件。
This code can use the Java Media Framework to save the animationto movie files.
我想这个端口code到一个纯粹的服务器端环境,使用Web UI工作。绘图code既可以在servlet容器内运行,或外部作为一个命令行程序。 (或者我可以选择不使用servlet容器,而使用命令行运行Java的Web服务器的新方式。)
I would like to port this code to a pure server-side environment, for working with a Web UI. The drawing code could either run inside the servlet container, or outside as a command-line program. (Or I could opt not to use a servlet container and instead use the newer ways of running Java web servers from the command line.)
我可以使用AWT和Swing的绘图功能,而不服务器上启动X Window系统?
Can I use AWT and Swing drawing features without starting the X Window System on the server?
推荐答案
这篇文章的 在Java SE平台<使用无头模式/ em>的概述强加这样的应用程序的限制。
The article Using Headless Mode in the Java SE Platform outlines the limitations imposed on such applications.
作为一个具体的例子 的JFreeChart
是一个图形程序广在台式机和servlet上下文中使用。对于后者,任何几个 ChartUtilities
可用于流中的无头环境中呈现的内容。
As a concrete example JFreeChart
is a graphic program widely used in both desktop and servlet contexts. For the latter, any of several ChartUtilities
may be used to stream rendered content in a headless environment.
另外,考虑 Java Web Start的的部署现有的Swing应用程序,例如的JFreeChart
演示看到这里。
Alternatively, consider Java Web Start to deploy an existing Swing application, for example the JFreeChart
demo seen here.
附录:此Oracle论坛线程说明Java媒体框架确实可以扔 HeadlessException的
;建议的解决方法是指定一个特定的系统属性值:
Addendum: This Oracle forum thread suggests that the Java Media Framework can indeed throw HeadlessException
; a suggested workaround is to specify a particular system property value:
-Dawt.toolkit=sun.awt.HeadlessToolkit
本的JFreeChart
螺纹建议 的Xvfb
或 VNC
作为替代,当无头
模式不可用。
This JFreeChart
forum thread suggests Xvfb
or vnc
as alternatives when headless
mode is not available.
这篇关于移植使用AWT和Swing绘制电影服务器端Java应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!