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"
Answer from nos on Stack Overflow
🌐
Java in&Out Blog
manismaran.wordpress.com › java_opts-java_opts-environment-variable-linux-java_opts-how-to-set-java_opts
java_opts + java_opts environment variable+ Linux java_opts+ how to set java_opts – Java in&Out Blog
March 22, 2016 - JVM Options on Windows (64 bit) set JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx2048m -XX:PermSize=32m set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=512m -Xss2m -XX:+UseConcMarkSweepGC set JAVA_OPTS=%JAVA_OPTS% -XX:+CMSClassUnloadingEnabled JVM Options on Linux and Mac OSX (64 bit) export JAVA_OPTS=-Xms1024m -Xmx8192m -XX:PermSize=32m -XX:MaxPermSize=8192m or export JAVA_OPTS="$JAVA_OPTS -Xms1024m -Xmx8192m -XX:PermSize=32m -XX:MaxPermSize=8192m" export JAVA_OPTS="$JAVA_OPTS -Xms1024m -Xmx2048m -XX:PermSize=32m" export JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=512m -Xss2m" export JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC" export JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled"…
🌐
Jira
mifosforge.jira.com › wiki › spaces › docs › pages › 115769361 › Setting+java+opts
Setting java opts - Mifos X User Zone - Confluence
export JAVA_OPTS="$JAVA_OPTS\ -server\ -Xms512m\ -Xmx512m · -XX:+HeapDumpOnOutOfMemoryError\ -XX:MaxPermSize=256m" Recommended for medium instance(3.75gb ram):- export JAVA_OPTS="$JAVA_OPTS\ -server\ -Xms1024m\ -Xmx1024m · -XX:+HeapDumpOnOutOfMemoryError\ -XX:MaxPermSize=512m" Recommended for large instance(8gb ram):- export JAVA_OPTS="$JAVA_OPTS\ -server\ -Xms2048m\ -Xmx2048m ·
🌐
DBeaver
dbeaver.com › cloudbeaver › administration
Command line parameters | CloudBeaver Documentation
November 26, 2025 - You can set the JAVA_OPTS environment variable with JVM parameters. This works for both manual startup and Docker containers. export JAVA_OPTS=-Xmx1000m ./run-cloudbeaver-server.sh
Top answer
1 of 1
12

You know how to set the variable in a shell, but for the record you can write:

export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on'

and all programs you start from this shell session after that will have the variable set.

If you want it to be set for every shell you start afterwards, add that line to ~/.profile as well. In that case it will apply to all future shells you start, but not any that are currently running.

.profile will generally work for the GUI as well, but that can be broken by system configuration and how you start things up. This is per-user configuration only.


If you want it set for every user all the time, you can add an assignment to /etc/environment. The format is a little different there: just KEY=VAL on separate lines, with no required quoting and none of anything else.

_JAVA_OPTIONS=-Dawt.useSystemAAFontSettings=on

This is parsed by the pam_env module. There is a per-user ~/.pam_environment file as well, which has the same effect for just the one user. These both require logging out and back in for the change to take effect. The variables will be set for every future login session, both at the console and in X.

Similarly, you can make a file in /etc/profile.d with an export statement in it and it will be loaded into every future session by any user. There will likely be some pre-existing files there to model it on, but just the export line above will be fine.


Alternatively, you can add the export statement in ~/.xinitrc (if you use startx), ~/.xsession, or ~/.xprofile. KDE also supports a directory ~/.kde/env that can contain as many shell files as you want, which contain export statements as above. I would probably prefer one of the other approaches.

🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › guides › troubleshoot › envvars002.html
The JAVA_TOOL_OPTIONS Environment Variable
April 21, 2026 - This environment variable allows you to specify the initialization of tools, specifically the launching of native or Java programming language agents using the -agentlib or -javaagent options. In the following example the environment variable is set so that the HPROF profiler is launched when the application is started: $ export JAVA_TOOL_OPTIONS="-agentlib:hprof" This variable can also be used to augment the command line with other options for diagnostic purposes.
🌐
Atlassian
sakaiproject.atlassian.net › wiki › spaces › DOC › pages › 17257302152
Java Environment Variables (2.7) - Documentation - Confluence
At a minimum add the following property settings to your JAVA_OPTS environment variable. We recommend that you define these settings in Tomcat's /bin directory in a file named setenv.sh (Unix/Mac) or setenv.bat (Windows). See the Tomcat section below for more details. ... export JAVA_OPTS='-server -Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:NewSize=192m -XX:MaxNewSize=384m -Djava.awt.headless=true -Dhttp.agent=Sakai -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dsun.lang.ClassLoader.allowArraySyntax=true'
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 73624417 › how-to-export-several-java-opts-to-bash-profile
java - How to export several JAVA_OPTS to bash_profile? - Stack Overflow
export JAVA_OPTS=-Djavax.net.ssl.trustStore="/Library/Java/JavaVirtualMachines/jdk-11.0.3.jdk/Contents/Home/lib/security/cacerts" -Djavax.net.ssl.trustAnchors="/Library/Java/JavaVirtualMachines/jdk-11.0.3.jdk/Contents/Home/lib/security/cacerts"
🌐
Codemia
codemia.io › home › knowledge hub › difference between _java_options, java_tool_options and java_opts
Difference between _JAVA_OPTIONS, JAVA_TOOL_OPTIONS and JAVA_OPTS | Codemia
January 27, 2025 - Like JAVA_TOOL_OPTIONS, it prints a stderr message confirming pickup. Because it overrides explicit arguments, it can silently change behavior that was intentionally set on the command line. It is HotSpot-specific. IBM J9, GraalVM native-image, and other non-HotSpot JVMs may not recognize it. This variable is not recognized by the JVM. It exists purely as a convention in startup scripts. ... export JAVA_OPTS="-Xmx1024m -Xms512m" ./catalina.sh start # Tomcat reads JAVA_OPTS in its script java -jar myapp.jar # This process ignores JAVA_OPTS entirely
🌐
GATK
gatk.broadinstitute.org › hc › en-us › community › posts › 5036300695195-Environment-JAVA-OPTS-are-ignored
Environment JAVA_OPTS are ignored – GATK
March 30, 2022 - REQUIRED for all errors and issues: a) GATK version used: gatk/4.2.4.1 I'm trying to set java options globally before running gatk, however, the options are ignored when I run gatk. ``` $export JAVA_OPTS="-Xms10g -Xmx10g" $ gatk HaplotypeCaller -h Using GATK jar /apps/gatk/4.2.4.1/gatk-package-4.2.4.1-local.jar Running: java -Dsamjdk.use_async_io_read_samtools=false -Dsamjdk.use_async_io_write_samtools=true -Dsamjdk.use_async_io_write_tribble=false -Dsamjdk.compression_level=2 -jar /apps/gatk/4.2.4.1/gatk-package-4.2.4.1-local.jar HaplotypeCaller -h [...] ``` As you can see from the output, the JAVA_OPTS are ignored.
🌐
GitHub
github.com › GoogleCloudPlatform › openjdk-runtime › issues › 43
Add `env JAVA_OPTS="$JAVA_OPTS"` to `exec "$@"` · Issue #43 · GoogleCloudPlatform/openjdk-runtime
January 18, 2017 - Maybe we change it to exec env JAVA_OPTS="$JAVA_OPTS" "$@" 2>&1? (I'm not sure if 2>&1 is needed.
Author   GoogleCloudPlatform
🌐
Liquibase
docs.liquibase.com › concepts › connections › java-opts-environment-variable.html
What are JAVA_OPTS environment variables?
You can include all Liquibase properties in the Liquibase properties file, or you can set them as Java system properties by using the JAVA_OPTS variable. If you are using an earlier version of Liquibase, you must set them using JAVA_OPTS.
🌐
GitHub
gist.github.com › shafinmahmud › 935f2fcf6c52e409cd516150974bb532
Configure Tomcat Environment variable · GitHub
Configure Tomcat Environment variable. GitHub Gist: instantly share code, notes, and snippets.
🌐
Baeldung
baeldung.com › home › devops › catalina_opts vs. java_opts in apache tomcat
CATALINA_OPTS vs. JAVA_OPTS in Apache Tomcat | Baeldung
January 8, 2024 - $ export CATALINA_OPTS="$CATALINA_OPTS -Dcustom.property=baeldung-example-value" In the above command, we added a custom property to the Tomcat server. Upon setting this environment and restarting the Tomcat server, the Java application and Tomcat server will access this custom property value.