loading...empty;done;/java-options-arguments/:-uriJava Options and Arguments | iNET.elastic Dev Docs

Java Options and Arguments

In order to ensure cost efficiency, all platform-managed Java servers are automatically configured to utilize memory in the most beneficial way. It is achieved by adjusting the main Java memory parameters based on resources allocated to a container.

Tip: Custom Java servers (e.g. inside Docker containers or VPS) can be optimized similarly using the Java Memory Agent add-on.

The default options can be manually changed to ensure high performance or to support any custom implementation.

1. In order to provide all the preferred Java options at once, the variables.conf file can be utilized.

Depending on a particular application server you are working with, the exact location may vary:

  • Tomcat, TomEE - /opt/tomcat/conf/variables.conf
  • Jetty - /opt/jetty/etc/variables.conf
  • Spring Boot - /opt/shared/conf/variables.conf
  • GlassFish - /opt/glassfish/glassfish/domains/domain1/config/variables.conf
  • Payara - /opt/payara/glassfish/domains/domain1/config/variables.conf
  • WildFly - /opt/wildfly/conf/variables.conf

variables.conf file for Java options

If needed, you can redefine the main memory options via container variables.

2. Don’t forget to Restart nodes to apply changes.

restart nodes button

That’s it! Now, your application is running with your custom Java options.

Redefining Main Java Parameters

Most of the essential memory parameters (-Xms, -Xmn, -Xmx, -Xminf, -Xmaxf, -XX:MaxPermSize, *-XX:+Use.GC) can be redefined using the dedicated environment variables.

As an example, you can Add the -Xmx option (i.e. maximum size for the Java heap memory):

add Java memory optimization variable

Tip: The platform supports two additional variables that allow setting up main RAM parameters as a percentage of the total memory available:

  • XMS_DEF_PERCENT - the initial size (%) of the memory allocation pool
  • XMX_DEF_PERCENT - the maximum size (%) of the memory allocation pool

These values are automatically validated - if XMS is bigger than XMX, its actual value is set equal to XMX.

Spring Boot and Java Engine Specific Variables

When operating with the Spring Boot and Java Engine templates, you can provide two additional variables:

  • JAVA_OPTS - to customize Java options for your app (similar to the variables.conf file)
  • JAVA_ARGS - to pass some custom arguments to your application main function

Spring Boot variables for Java options arguments

Don’t forget to restart your application server(s) in order to apply changes.

What’s next?