对于 java 1.4以上,启动java时加上 -djava.awt.headless=true 的参数。对于 java 1.4 以前,下载 xvfb 或者其他的虚拟 x-window 软件,再在 java 运行环境里的 display 作相应改变。
对于 resin,具体的修改办法是,修改 httpd.sh 文件,把其中的 args= 行修改为 args=-djava.awt.headless=true。
转载自http://shaofanyun.mblogger.cn/(部分)
例如: catalina.sh
#!/bin/sh
# -----------------------------------------------------------------------------
# start/stop script for the catalina server
#
# environment variable prequisites
#
# catalina_home may point at your catalina "build" directory.
#
# catalina_base (optional) base directory for resolving dynamic portions
# of a catalina installation. if not present, resolves to
# the same directory that catalina_home points to.
#
# catalina_opts (optional) java runtime options used when the "start",
# "stop", or "run" command is executed.
#
# catalina_tmpdir (optional) directory path location of temporary directory
# the jvm should use (java.io.tmpdir). defaults to
# $catalina_base/temp.
#
# java_home must point at your java development kit installation.
#
# java_opts (optional) java runtime options used when the "start",
# "stop", or "run" command is executed.
#
# jpda_transport (optional) jpda transport used when the "jpda start"
# command is executed. the default is "dt_socket".
#
# jpda_address (optional) java runtime options used when the "jpda start"
# command is executed. the default is 8000.
#
# jsse_home (optional) may point at your java secure sockets extension
# (jsse) installation, whose jar files will be added to the
# system class path used to start tomcat.
#
# catalina_pid (optional) path of the file which should contains the pid
# of catalina startup java process, when start (fork) is used
#
# $id: catalina.sh,v 1.13.2.1 2004/08/21 15:49:49 yoavs exp $
# -----------------------------------------------------------------------------
java_home=/opt/j2sdk1.4.2_04
catalina_home=/opt/services/tomcat
# os specific support. $var _must_ be set to either true or false.
cygwin=false
os400=false
case "`uname`" in
cygwin*) cygwin=true;;
os400*) os400=true;;
esac
# resolve links - $0 may be a softlink
prg="$0"
while [ -h "$prg" ]; do
ls=`ls -ld "$prg"`
link=`expr "$ls" : '.*-> /(.*/)$'`
if expr "$link" : '.*/.*' > /dev/null; then
prg="$link"
else
prg=`dirname "$prg"`/"$link"
fi
done
# get standard environment variables
prgdir=`dirname "$prg"`
# only set catalina_home if not already set
[ -z "$catalina_home" ] && catalina_home=`cd "$prgdir/.." ; pwd`
if [ -r "$catalina_home"/bin/setenv.sh ]; then
. "$catalina_home"/bin/setenv.sh
fi
# for cygwin, ensure paths are in unix format before anything is touched
if $cygwin; then
[ -n "$java_home" ] && java_home=`cygpath --unix "$java_home"`
[ -n "$catalina_home" ] && catalina_home=`cygpath --unix "$catalina_home"`
[ -n "$catalina_base" ] && catalina_base=`cygpath --unix "$catalina_base"`
[ -n "$classpath" ] && classpath=`cygpath --path --unix "$classpath"`
[ -n "$jsse_home" ] && jsse_home=`cygpath --absolute --unix "$jsse_home"`
fi
# for os400
if $os400; then
# set job priority to standard for interactive (interactive - 6) by using
# the interactive priority - 6, the helper threads that respond to requests
# will be running at the same priority as interactive jobs.
command='chgjob job('$jobname') runpty(6)'
system $command
# enable multi threading
export qibm_multi_threaded=y
fi
# get standard java environment variables
if [ -r "$catalina_home"/bin/setclasspath.sh ]; then
basedir="$catalina_home"
. "$catalina_home"/bin/setclasspath.sh
else
echo "cannot find $catalina_home/bin/setclasspath.sh"
echo "this file is needed to run this program"
exit 1
fi
# add on extra jar files to classpath
if [ -n "$jsse_home" ]; then
classpath="$classpath":"$jsse_home"/lib/jcert.jar:"$jsse_home"/lib/jnet.jar:"$jsse_home"/lib/jsse.jar
fi
classpath="$classpath":"$catalina_home"/bin/bootstrap.jar:"$catalina_home"/bin/commons-logging-api.jar
if [ -z "$catalina_base" ] ; then
catalina_base="$catalina_home"
fi
if [ -z "$catalina_tmpdir" ] ; then
# define the java.io.tmpdir to use for catalina
catalina_tmpdir="$catalina_base"/temp
fi
# for cygwin, switch paths to windows format before running java
if $cygwin; then
java_home=`cygpath --absolute --windows "$java_home"`
catalina_home=`cygpath --absolute --windows "$catalina_home"`
catalina_base=`cygpath --absolute --windows "$catalina_base"`
catalina_tmpdir=`cygpath --absolute --windows "$catalina_tmpdir"`
classpath=`cygpath --path --windows "$classpath"`
[ -n "$jsse_home" ] && jsse_home=`cygpath --absolute --windows "$jsse_home"`
java_endorsed_dirs=`cygpath --path --windows "$java_endorsed_dirs"`
fi
# ----- execute the requested command -----------------------------------------
echo "using catalina_base: $catalina_base"
echo "using catalina_home: $catalina_home"
echo "using catalina_tmpdir: $catalina_tmpdir"
echo "using java_home: $java_home"
if [ "$1" = "jpda" ] ; then
if [ -z "$jpda_transport" ]; then
jpda_transport="dt_socket"
fi
if [ -z "$jpda_address" ]; then
jpda_address="8000"
fi
if [ -z "$jpda_opts" ]; then
jpda_opts="-xdebug -xrunjdwp:transport=$jpda_transport,address=$jpda_address,server=y,suspend=n"
fi
catalina_opts="$catalina_opts $jpda_opts"
shift
fi
if [ "$1" = "debug" ] ; then
if $os400; then
echo "debug command not available on os400"
exit 1
else
shift
if [ "$1" = "-security" ] ; then
echo "using security manager"
shift
exec "$_runjdb" $java_opts $catalina_opts /
-djava.endorsed.dirs="$java_endorsed_dirs" -classpath "$classpath" /
-sourcepath "$catalina_home"/../../jakarta-tomcat-catalina/catalina/src/share /
-djava.security.manager /
-djava.security.policy=="$catalina_base"/conf/catalina.policy /
-dcatalina.base="$catalina_base" /
-dcatalina.home="$catalina_home" /
-djava.awt.headless=true /
-djava.io.tmpdir="$catalina_tmpdir" /
org.apache.catalina.startup.bootstrap "$@" start
else
exec "$_runjdb" $java_opts $catalina_opts /
-djava.endorsed.dirs="$java_endorsed_dirs" -classpath "$classpath" /
-sourcepath "$catalina_home"/../../jakarta-tomcat-catalina/catalina/src/share /
-dcatalina.base="$catalina_base" /
-dcatalina.home="$catalina_home" /
-djava.awt.headless=true /
-djava.io.tmpdir="$catalina_tmpdir" /
org.apache.catalina.startup.bootstrap "$@" start
fi
fi
elif [ "$1" = "run" ]; then
shift
if [ "$1" = "-security" ] ; then
echo "using security manager"
shift
exec "$_runjava" $java_opts $catalina_opts /
-djava.endorsed.dirs="$java_endorsed_dirs" -classpath "$classpath" /
-djava.security.manager /
-djava.security.policy=="$catalina_base"/conf/catalina.policy /
-dcatalina.base="$catalina_base" /
-dcatalina.home="$catalina_home" /
-djava.awt.headless=true /
-djava.io.tmpdir="$catalina_tmpdir" /
org.apache.catalina.startup.bootstrap "$@" start
else
exec "$_runjava" $java_opts $catalina_opts /
-djava.endorsed.dirs="$java_endorsed_dirs" -classpath "$classpath" /
-dcatalina.base="$catalina_base" /
-dcatalina.home="$catalina_home" /
-djava.awt.headless=true /
-djava.io.tmpdir="$catalina_tmpdir" /
org.apache.catalina.startup.bootstrap "$@" start
fi
elif [ "$1" = "start" ] ; then
shift
touch "$catalina_base"/logs/catalina.out
if [ "$1" = "-security" ] ; then
echo "using security manager"
shift
"$_runjava" $java_opts $catalina_opts /
-djava.endorsed.dirs="$java_endorsed_dirs" -classpath "$classpath" /
-djava.security.manager /
-djava.security.policy=="$catalina_base"/conf/catalina.policy /
-dcatalina.base="$catalina_base" /
-dcatalina.home="$catalina_home" /
-djava.awt.headless=true /
-djava.io.tmpdir="$catalina_tmpdir" /
org.apache.catalina.startup.bootstrap "$@" start /
>> "$catalina_base"/logs/catalina.out 2>&1 &
if [ ! -z "$catalina_pid" ]; then
echo $! > $catalina_pid
fi
else
"$_runjava" $java_opts $catalina_opts /
-djava.endorsed.dirs="$java_endorsed_dirs" -classpath "$classpath" /
-dcatalina.base="$catalina_base" /
-dcatalina.home="$catalina_home" /
-djava.awt.headless=true /
-djava.io.tmpdir="$catalina_tmpdir" /
org.apache.catalina.startup.bootstrap "$@" start /
>> "$catalina_base"/logs/catalina.out 2>&1 &
if [ ! -z "$catalina_pid" ]; then
echo $! > $catalina_pid
fi
fi
elif [ "$1" = "stop" ] ; then
shift
force=0
if [ "$1" = "-force" ]; then
shift
force=1
fi
"$_runjava" $java_opts $catalina_opts /
-djava.endorsed.dirs="$java_endorsed_dirs" -classpath "$classpath" /
-dcatalina.base="$catalina_base" /
-dcatalina.home="$catalina_home" /
-djava.awt.headless=true /
-djava.io.tmpdir="$catalina_tmpdir" /
org.apache.catalina.startup.bootstrap "$@" stop
if [ $force -eq 1 ]; then
if [ ! -z "$catalina_pid" ]; then
echo "killing: `cat $catalina_pid`"
kill -9 `cat $catalina_pid`
fi
fi
elif [ "$1" = "version" ] ; then
"$_runjava" /
-classpath "$catalina_home/server/lib/catalina.jar" /
org.apache.catalina.util.serverinfo
else
echo "usage: catalina.sh ( commands ... )"
echo "commands:"
if $os400; then
echo " debug start catalina in a debugger (not available on os400)"
echo " debug -security debug catalina with a security manager (not available on os400)"
else
echo " debug start catalina in a debugger"
echo " debug -security debug catalina with a security manager"
fi
echo " jpda start start catalina under jpda debugger"
echo " run start catalina in the current window"
echo " run -security start in the current window with security manager"
echo " start start catalina in a separate window"
echo " start -security start in a separate window with security manager"
echo " stop stop catalina"
echo " stop -force stop catalina (followed by kill -kill)"
echo " version what version of tomcat are you running?"
exit 1
fi
闽公网安备 35060202000074号