Running without a GUI
Many environments, such as mainframe machines and dedicated servers, do not support a display, keyboard, or mouse. JReport Server supports Java headless implementation, in which case you do not have to install a third-party tool, such as PJA, XWindows, or XVFB, in order to run JReport in a non-GUI environment.
Using Java headless implementation
JReport Server runs fluently in headless environments. What you need to do is make some simple configuration changes before starting JReport Server in headless environments.
To launch JReport Server in a headless environment:
- Add
-Djava.awt.headless=true
as a JVM parameter before starting JReport Server.
- Start JReport Server.
Note: If JDK 6 is used, it is not necessary to add the parameter -Djava.awt.headless
manually, because JDK 6 can automatically give a value to the parameter according to the environment the server will run. For example, if it is headless, the true value will be given.
Using a third-party tool (deprecated)
The method of using a third-party tool is no longer needed but is still available in this release. It may be removed in the future. The following introduces three ways to run JReport Server on Unix without GUI.
Running with XVFB
XVFB is an acronym of the Xserver Virtual Frame Buffer. It can provide a virtual Xserver and release you from the need of a real Xserver. It runs without a head or graphics card. XVFB is freeware and can be obtained from x.org's X11R6 distribution. Compiling it is supposedly difficult, however, there are some Solaris binaries on certain sites, including:
Take the following steps to run JReport Server with XVFB:
- Install XVFB.
- To have XVFB start up automatically when a workstation boots, you can add the Virtual Frame Buffer to the Automatic Startup. That is, write a script
/etc/init.d/xvfb
as follows, and make it executable.
#!/bin/sh
mode=$1
case "$mode" in
'start')
# start the X Virtual Framebuffer (Xvfb)
if [ -f /usr/X11R6/bin/Xvfb ]; then
echo "***Starting up the Virtual Frame Buffer on Screen 1***"
/usr/X11R6/bin/Xvfb :1 -screen 0 1152x900x8 &
fi
;;
*)
echo " Usage: "
echo " $0 start (start XVFB)"
echo " $0 stop (stop XVFB - not supported)"
exit 1
;;
esac
exit 0
|
Then create a soft link to /etc/rc2.d/S98xvfb
:
ln -s /etc/init.d/xvfb /etc/rc2.d/S98xvfb
If you need not to start XVFB automatically, you can manually start up XVFB:
/usr/X11R6/bin/Xvfb :1 -screen 0 1152x900x8 &
- Set DISPLAY to screen 1 (assuming that JReport Server is running on machine jaguar).
DISPLAY=jaguar:1.0
export DISPLAY
Then, you can start JReport Server. Logging out the terminal may result in JReport Server shutting down. To avoid this, you can first start JReport Server in the background using the command nohup: nohup ./JRServer &
. This command will continue running programs specified by you and enables JReport Server to ignore hangup signals.
Running with PJA toolkit
When there is neither X Window, nor XVFB available, a PJA (Pure Java AWT) Toolkit is supported to run JReport Server. This is a Java library for drawing graphics developed by eTeks. It supplies a replacement AWT toolkit and eliminates the requirement of an X display. To use it:
- Install PJA. The PJA package is not included in our product, go to http://www.eteks.com/pja/en/ to download PJA and install it.
- Install JReport Server.
- Assuming that jrserver-xxx-linux.bin has been used to install JReport Server on a Non-GUI platform, modify the file JRServer.sh in
<install_root>\bin
by appending /pja_2.4/lib/pjatools.jar
to the class path, and add the following options.
- -Xbootclasspath/a:pja.jar - (changing classpath is not enough).
- -Dawt.toolkit=com.eteks.awt.PJAToolkit - This enables the changing of AWT Toolkit.
- -Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment - This enables the changing of the Graphics environment.
- -Djava2d.font.usePlatformFont=false - This avoids the class sun.java2d.loops.RasterOutputManager calling the native method getPlatformFontVar(), which can cause a JVM crash.
- -Djava.awt.fonts=path - With path equal to the directory where the Lucida *.ttf files can be found. You can add to the path other directories containing True Type Fonts by using a separator.
- Either -Duser.home=dir with dir equal to the directory where the sub directory lib containing PJA font.properties file can be found, or add
lib/font.properties
to the user.home system property.
Below is an example of the modified file JRServer.sh that is used to start up JReport Server:
#!/bin/sh
CLASSPATH=$REPORTHOME/lib/commons-net-ftp-2.0.0.jar:
$REPORTHOME/lib/sac.jar:$REPORTHOME/lib/servlet.jar:
$REPORTHOME/lib/ant.jar:$REPORTHOME/lib/jasper-compiler.jar:
$REPORTHOME/lib/jasper-runtime.jar:$REPORTHOME/lib/JREngine.jar:
$REPORTHOME/lib/JRESServlets.jar:$REPORTHOME/lib/JREntServer.jar:
$REPORTHOME/lib/maintain.jar:$REPORTHOME/lib/mail-1.4.jar:
$REPORTHOME/lib/activation-1.1.jar:$REPORTHOME/lib/JRWebDesign.jar:
$REPORTHOME/lib/itext_1.5.4.jar:$REPORTHOME/lib/poiHSSF_151.jar:
$REPORTHOME/lib/xercesImpl.jar:$REPORTHOME/lib/xml-apis.jar:
$REPORTHOME/lib/hsqldb.jar:$REPORTHOME/lib/tar.jar:
$REPORTHOME/lib/jai_core.jar:$REPORTHOME/lib/jai_codec.jar:
$REPORTHOME/lib/commons-codec-1.2.jar:$REPORTHOME/lib/log4j-1.2.8.jar:
$REPORTHOME/lib/jsch-0.1.30.jar:$REPORTHOME/derby/lib/derby.jar:
$REPORTHOME/derby/lib/derbyclient.jar:$REPORTHOME/derby/lib/derbynet.jar:
$REPORTHOME/derby/lib/derbytools.jar:$JAVAHOME/lib/tools.jar:$ADDCLASSPATH
cd $REPORTHOME/bin
$JAVAHOME/bin/java -Dawt.toolkit=com.eteks.awt.PJAToolkit
-Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment
-Djava2d.font.usePlatformFont=false
-Djava.awt.fonts=/usr/j2se/jre/lib/fonts:
/JREntServer/font:/usr/openwin/lib/X11/fonts/TrueType
-Dinstall.root=$REPORTHOME/ -Djreport.url.encoding=UTF-8 -Xmx512m
-Dreporthome=$REPORTHOME jet.server.JREntServer "$@"
|
Notes:
- Printing reports is not supported.
- To support multiple encoding, the file charsets.jar in
jre\lib
should be added to -Xbootclasspath
. Without this Jar file, only the default encoding (iso8859-1) can be applied to JReport. For the encoding types which are supported by charsets.jar, refer to the website http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html.
- If you are using other True Type Fonts instead of the fonts in X11, you should add the location of the Lucida*.ttf files directory to
-Djava.awt.fonts
.
Starting from a telnet session with an X server installed
If you are using telnet to start JReport and your Unix has an X server installed, you can directly point your display to your X server:
$ DISPLAY=hostname(or IP address):0.0
$ export DISPLAY
Then, you can run JReport Server or your application with JReport embedded.