Configuration from Command Line

The Wrapper allows any configuration property to be set from the command line. This can be useful in situations where configuration values can only be set at runtime. An example can be seen by looking at the shell script (sh) shipped with the Wrapper.

Configuration properties can be set on the command line by including them after the configuration file is loaded when the Wrapper is launched. Each property consists of the formation like "a property name = the property's value". The syntax is exactly the same as in the wrapper.conf file.

Example :

In this example, a Java application is being launched using Wrapper with debug logging enabled.

Windows NT/2000:
wrapper.exe -c ..\conf\wrapper.conf wrapper.debug=TRUE
Linux / Solaris:
./wrapper ../conf/wrapper.conf wrapper.debug=TRUE

Priority :

Properties set on the command line have priority over other default properties, and will override any default property value set in the configuration file or any "include file" (cascading style).

Properties can be specified from the command line when using any of the Wrapper commands, including the -i command, used to install the application as a service on Windows systems.

When running the Wrapper and its JVM as a console application using the -c command, the specified properties will override any values in the wrapper.conf file and be used when launching the JVM.

Likewise, the -i command, which is used to install the Wrapper as a service, will remember the specified properties and then use them later when the service is actually started. Likewise, the specified properties will be used to override values in the wrapper.conf file while installing the service.

All other commands will make use of command line properties to override values in the configuration file. These will effect logging or the way the service is referenced. They will have no effect on the running JVM. It is not possible for example to pass a property value to a service while starting it with the -t command for example.

Quoted Spaces:


Properties specified on the command line can not contain unquoted spaces. If you need to include spaces in the value of the property, simply include the entire pair of "property name and value" in quotes:

Example(include unquoted spaces):
wrapper.exe -c ..\conf\wrapper.conf "\My App\jre\bin\java.exe"

Quoting on Windows:


When quoting path values on Windows, please keep in mind a problem with the way Windows parses quoted values. It treats all backslashes in the quoted value normally EXCEPT for a trailing backslash. In the following example, you will see that the trailing backslash is escaping the quote itself resulted in unintended arguments being passed to the Wrapper.

wrapper.exe -c ..\conf\wrapper.conf "wrapper.working.dir=C:\" wrapper.debug=TRUE"

The intended operation is to call the Wrapper with the arguments ( [-c], [..\conf\wrapper.conf], [wrapper.working.dir=C:\], and [wrapper.debug=TRUE]). What actually happens, however, is that the second quote is escaped resulting in the following 3 arguments; [-c], [..\conf\wrapper.conf], [wrapper.working.dir=C:" wrapper.debug=TRUE].

The first solution is to never have a trailing backslash. This is not possible with the "C:\" example above however. Another good solution that we came across is to add a trailing period after the backslash. This results in a directory "C:\.", which has the same meaning as "C:\" but that is parsed by Windows correctly.

wrapper.exe -c ..\conf\wrapper.conf "wrapper.working.dir=C:\." wrapper.debug=TRUE"

Referencia: Iniciar su Aplicación con el Wrapper