If you are working with WildFly or JBoss EAP in 2025, managing system properties and application configurations effectively is essential for containerized deployments, CI/CD pipelines, and cloud-native workloads. Whether you need to inject environment-specific variables, manage secret values, or configure tuning parameters, understanding how to set and load properties in WildFly ensures your applications remain portable, maintainable, and aligned with modern DevOps practices. This updated guide shows multiple methods to inject system properties into WildFly, including CLI commands, standalone.xml edits, and environment variable approaches suitable for Kubernetes and OpenShift deployments.
In a Bare Metal installation of WildFly, there are mainly three strategies to load Properties:
- Add the System Properties as JVM arguments to the start up script
- Include the System Properties in WildFly Configuration
- Include the Application Properties in a module of the application server
- Inject the System Properties through an environment variable (WildFly 25 or newer)
Let’s see them all in detail.
Setting System Property as JVM arguments
Firstly, you can add a System Property by using -D as for every Java application. For example, you can add MSG to the start up script of WildFly as follows:
$ ./standalone.sh -DMSG=Hello
Next, edit the standalone.conf file and add it to the JAVA_OPTS variable:
JAVA_OPTS="$JAVA_OPTS -Dproperty=value"
Finally, in domain mode, add it as JVM Option in the host.xml file:
<jvm-options>
<option value="-server"/>
<option value="-XX:MetaspaceSize=96m"/>
<option value="-XX:MaxMetaspaceSize=256m"/>
<option value="-Dproperty=value"/>
</jvm-options>
Setting System Properties into WildFly configuration
The other option requires that you either add your system property directly into the configuration file or use the CLI. Let’s see first the configuration file approach:
- In the Standalone mode, the change will go into standalone.xml
- In the Domain mode, the change will go into domain.xml
Add the system-properties element right after the extensions element.
<extensions> . . . </extensions> <system-properties> <property name="my.project.dir" value="/home/francesco"/> </system-properties>
Finally, you can read/write System Properties from the CLI as follows:
$ ./bin/jboss-cli.sh
[standalone@localhost:9999 /] /system-property=foo:add(value=bar)
[standalone@localhost:9999 /] /system-property=foo:read-resource
{
"outcome" => "success",
"result" => {"value" => "bar"}
}
How to load Application properties from a folder
If you want to load your Applicaion Properties from a folder, we recommend to place your property file in a module and use that module in your application.
Let’s see how to do it. Place the property file (say file.properties) in the “bin” folder of the application server and launch the jboss-cli.sh:
$ jboss-cli.sh
Execute the following command:
module add --name=configuration --resources=file.properties
Then, the following configuration will be created under the “modules” folder:
configuration/
└── main
├── file.properties
└── module.xml
As you can see, our module named “configuration” has been defined. The file module.xml contains the list of resources available in that module:
<?xml version='1.0' encoding='UTF-8'?>
<module xmlns="urn:jboss:module:1.1" name="configuration">
<resources>
<resource-root path="file.properties"/>
</resources>
</module>
Finally, if you want to use this module at application level, you can add it to your jboss-deployment-structure.xml:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="configuration" export="TRUE"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
As an alternative, if the property file is shared between multiple applications, you can include it in the list of global modules, within your server configuration:
<subsystem xmlns="urn:jboss:domain:ee:1.0" >
<global-modules>
<module name="configuration" slot="main" />
</global-modules>
</subsystem>
When the Property file is available as module, to load it, you can use the following code:
Properties props = new Properties();
try {
java.io.InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("file.properties");
// Read the Properties file
props.load(stream);
} catch (IOException e) {
e.printStackTrace();
}
}
Setting System Properties at application level
Next, it is worth mentioning that WildFly is able to use the META-INF/jboss.properties file to set System Properties at deployment level.
Here is an example application which includes the jboss-properties file to set System Properties only for that deployment:
test.war
├── index.jsp
└── META-INF
└── jboss.properties
Therefore, if the jboss.properties includes the following:
foo=bar
Then, your index.jsp will display the property “foo”:
<%
out.println("foo: " + System.getProperty("foo"));
%>
Injecting properties through environment variables
As the cloud use-cases rely often on environment variables rather than system properties, it is also possible to inject properties from environment variables as well..
Please note, is is required to use WildFly 25 or newer to use this feature.
For example, if you have the following configuration:
<file relative-to="jboss.server.log.dir" path="${log_file:server.log}"/>
Then, you can inject the value of the path element as follows:
$ export LOG_FILE=wildfly.log $ ./standalone.sh
Finally, note that the System property will take precedence over the environment variable if both are defined.
Setting Properties in MicroProfile applications
Beyond setting properties in standalone.xml or using CLI commands, consider using MicroProfile Config, which is natively supported on WildFly, to externalize and dynamically inject configuration into your applications without restarting the server. With MicroProfile Config, you can load properties from environment variables, system properties, and external files, enabling 12-Factor App best practices for modern workloads. Check this article to learn more: Configuring Microservices with MicroProfile Configuration
Adding properties from the CLI
JBoss CLI does not support file operations such as setting properties from a file. However, you can easily use as workaround a bash script which reads a file in a variable. Then, you can expand the shell variable when calling the CLI. For example:
CUSTOMERS=$(cat customers.txt )
./jboss-cli.sh -c --commands="/system-property=users:add(value=\"${CUSTOMERS}\")
Setting Properties in Kubernetes environment
Finally, if you are deploying your applications on OpenShift or Kubernetes, the most common option to pass properties to WildFly runtime is via Environment Properties. For example, if you are deploying WildFly using Helm Charts, then you can add them in the env section of your YAML file:
build:
uri: https://github.com/wildfly/quickstart.git
ref: 27.0.0.Final
contextDir: microprofile-config
mode: bootable-jar
env:
- name: MAVEN_ARGS_APPEND
value: -Pbootable-jar-openshift -Djkube.skip=true
deploy:
replicas: 1
env:
- name: CONFIG_PROP
value: Hello from OpenShift
Besides, if you want to externalize the properties, for example from a ConfigMap, then you can reference the ConfigMap from your deploy section as follows:
deploy:
replicas: 1
envFrom:
- configMapRef:
name: <name-of-your-config-map>
To learn more about deploying WildFly on Kubernetes using Helm Charts check this article: WildFly on the Cloud with Helm
As you can see the The “URLList” is a comma-separated list of URL strings from which to load properties file-formatted content while the “Properties” is a specification of multiple property name=value pairs