> For the complete documentation index, see [llms.txt](https://coldbox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coldbox.ortusbooks.com/getting-started/configuration/system-settings.md).

# System Settings

Access Java system properties and server environment variables with getSystemSetting(), getSystemProperty(), and getEnv().

ColdBox makes it easy to access the configuration stored in your Java system properties and your server's environment variables, even if you don't know which one it is in! Three methods are provided for your convenience:

| Name                | Arguments               | Description                                                                                         |
| ------------------- | ----------------------- | --------------------------------------------------------------------------------------------------- |
| `getSystemSetting`  | `( key, defaultValue )` | Looks for `key` in properties first, env second. Returns the `defaultValue` if neither exist.       |
| `getSystemProperty` | `( key, defaultValue )` | Returns the Java System property for `key`. Returns the `defaultValue` if it does not exist.        |
| `getEnv`            | `( key, defaultValue )` | Returns the server environment variable for `key`. Returns the `defaultValue` if it does not exist. |

## Accessing System Settings in `config/ColdBox.bx` (or `.cfc` for CFML) or a `ModuleConfig.bx` (or `.cfc` for CFML)

If you are inside `config/ColdBox.bx` (or `.cfc` for CFML) or a `ModuleConfig.bx` (or `.cfc` for CFML) or a `config/WireBox.bx` (or `.cfc` for CFML) you can use the three system settings functions directly! No additional work required.

## Accessing System Settings in `Application.bx` (or `.cfc` for CFML)

If you would like to access these methods in your `Application.bx` (or `.cfc` for CFML), create an instance of `coldbox.system.core.delegates.Env` and access them off of that class. This is required when adding a datasource from environment variables.

Example:

{% tabs %}
{% tab title="BoxLang" %}
{% code title="Application.cfc" %}

```js

class {

    variables.env = new coldbox.system.core.delegates.Env();

    this.datasources[ "my_datasource" ] = {
        driver = env.getSystemSetting( "DB_DRIVER" ),
        host = env.getSystemSetting( "DB_HOST" ),
        port = env.getSystemSetting( "DB_PORT" ),
        database = env.getSystemSetting( "DB_DATABASE" ),
        username = env.getSystemSetting( "DB_USERNAME" ),
        password = env.getSystemSetting( "DB_PASSWORD" )
    };

}
```

{% endcode %}
{% endtab %}

{% tab title="CFML" %}
{% code title="Application.cfc" %}

```cfscript

component {

    variables.env = new coldbox.system.core.delegates.Env();

    this.datasources[ "my_datasource" ] = {
        driver = env.getSystemSetting( "DB_DRIVER" ),
        host = env.getSystemSetting( "DB_HOST" ),
        port = env.getSystemSetting( "DB_PORT" ),
        database = env.getSystemSetting( "DB_DATABASE" ),
        username = env.getSystemSetting( "DB_USERNAME" ),
        password = env.getSystemSetting( "DB_PASSWORD" )
    };

}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Accessing System Settings in other files

If you need to access these configuration values in other classes, consider adding the values to your [ColdBox settings](https://github.com/ortus-docs/coldbox-docs/tree/v8.x/getting-started/configuration-directives/coldbox.md#settings) and injecting the values into your other classes [via dependency injection.](/getting-started/configuration/using-settings.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://coldbox.ortusbooks.com/getting-started/configuration/system-settings.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
