Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

JVM system properties support - AWS SDKs and Tools

JVM system properties support

JVM system properties provide another way to specify configuration options and credentials for SDKs that run on the JVM such as the AWS SDK for Java and the AWS SDK for Kotlin. For a list of JVM system properties supported by SDKs, see Settings reference.

Precedence of options
  • If you specify a setting by using its JVM system property, it overrides any value found in environment variables or loaded from a profile in the shared AWS config and credentials files.

  • If you specify a setting by using its environment variable, it overrides any value loaded from a profile in the shared AWS config and credentials files.

How to set JVM system properties

You can set JVM system properties several ways.

On the command line

Set JVM system properties on the command-line when invoking the java command by using the -D switch. The following command configures the AWS Region globally for all service clients unless you explicitly override the value in code.

java -Daws.region=us-east-1 -jar <your_application.jar> <other_arguments>

If you need to set multiple JVM system properties, specify the -D switch multiple times.

With an environment variable

If you can't access the command line to invoke the JVM to run your application, you can use the JAVA_TOOL_OPTIONS environment variable to configure command-line options. This approach is useful in situations such as running an AWS Lambda function on the Java runtime or running code in an embedded JVM.

The following example configures the AWS Region globally for all service clients unless you explicitly override the value in code.

Linux, macOS, or Unix
$ export JAVA_TOOL_OPTIONS="-Daws.region=us-east-1"

Setting the environment variable changes the value used until the end of your shell session, or until you set the variable to a different value. You can make the variables persistent across future sessions by setting them in your shell's startup script.

Windows Command Prompt
C:\> setx JAVA_TOOL_OPTIONS -Daws.region=us-east-1

Using set to set an environment variable changes the value used until the end of the current Command Prompt session, or until you set the variable to a different value. Using setx to set an environment variable changes the value used in both the current Command Prompt session and all Command Prompt sessions that you create after running the command. It does not affect other command shells that are already running at the time you run the command.

$ export JAVA_TOOL_OPTIONS="-Daws.region=us-east-1"

Setting the environment variable changes the value used until the end of your shell session, or until you set the variable to a different value. You can make the variables persistent across future sessions by setting them in your shell's startup script.

At runtime

You can also set JVM system properties at runtime in code by using the System.setProperty method as shown in the following example.

System.setProperty("aws.region", "us-east-1");
Important

Set any JVM system properties before you initialize SDK service clients, otherwise service clients may use other values.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.