In which file do the export JAVA_OPTS="" Parameters go?
When I do the following command:
root@starwars:/# export JAVA_OPTS="-Xms756m -Xmx756m -Xss128m -Xmn512m"
In which file will the va开发者_运维知识库lues "-Xms756m -Xmx756m -Xss128m -Xmn512m"
be written?
The startup scripts of tomcat will run a setenv.sh
file if it exists. Create it (in the tomcat bin/
) directory and write your customization there, e.g. that file can just contain the line:
export JAVA_OPTS="-Xms756m -Xmx756m -Xss128m -Xmn512m"
when you do it from the command line, the params are not written anywhere. They exist only for your current bash session.
Put export JAVA_OPTS="..."
in your ~/.bashrc or ~/.bash_profile files to persist them. If you are on OS X you will have to source the .bashrc file from .profile.
simply add it under startup.sh
like this
export JAVA_OPTS="-server -Xms2048M -Xmx2048M -XX:MaxPermSize=128M"
Hope it works.
The statement just assigns the environment variable JAVA_OPTS the given value. There is no file involved here.
Later JAVA_OPTS maybe passed to the command line of java executable
Those values will be used by catalina.sh, e.g.
"$_RUNJAVA" "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS \
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
-Dcatalina.base="$CATALINA_BASE" \
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 &
So if you export that variable and then start Tomcat in the same console (e.g. using "catalina start" or "startup") then the JVM will be created with those parameters.
you can add them either to the /etc/init.d/tomcat script or /opt/tomcat/bin/startup.sh (or catalina.sh) for when tomcat is started
If you need this configuration only for a specific application you can set it directly in your IDE.
- Open the "Edit Run/Debug Configuration" dialog
- click the "Configuration Tab"
- write the line in the "VM options" field
Run!
精彩评论