Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the JAVA_OPTS environment variable?

Tags:

java

jvm

How do I use the JAVA_OPTS variable to configure a web server (a linux server)?

How can I set -Djava.awt.headless=true using JAVA_OPTS?

like image 213
Sreekanth P Avatar asked Mar 09 '11 05:03

Sreekanth P


People also ask

What is JAVA_OPTS environment variable?

JAVA_OPTS is an environment variable that you can set to pass custom settings to the Java Virtual Machine (JVM) that runs Liquibase.

How do I change JVM settings?

Configuring JVM OptionsAccess the Server Manager, and choose the Java tab. Click JVM Options and make the necessary changes. Click OK.

How do you call an environment variable in Java?

There are two ways to get the environment variable in Java, by using System properties or by using System. getEnv(). System properties provide only a limited set of predefined environment variables like java. classpath, for retrieving Java Classpath or java.


2 Answers

JAVA_OPTS is the standard environment variable that some servers and other java apps append to the call that executes the java command.

For example in tomcat if you define JAVA_OPTS='-Xmx1024m', the startup script will execute java org.apache.tomcat.Servert -Xmx1024m

If you are running in Linux/OSX, you can set the JAVA_OPTS, right before you call the startup script by doing

JAVA_OPTS='-Djava.awt.headless=true' 

This will only last as long as the console is open. To make it more permanent you can add it to your ~/.profile or ~/.bashrc file.

like image 187
CarlosZ Avatar answered Sep 22 '22 07:09

CarlosZ


Just figured it out in Oracle Java the environmental variable is called: JAVA_TOOL_OPTIONS rather than JAVA_OPTS

like image 24
Madcat Avatar answered Sep 21 '22 07:09

Madcat