Home / Java Techs / Grails / Using System properties in Grails

Using System properties in Grails

Print Friendly, PDF & Email

Retrieving a few of system variables is inevitable in developing computer applications within any environment. In this post, we would show you system variables existing once the application is loaded and how to retrieve a specific variable to pass it to another routine.

To do so, the following statements will print out all the existing values of System variables.

The result often looks like

Let’s give an example.

We often want to get the directory of the currently logged-in user to make other directories to store exported files or backup data, for instance. To do so, the snippet below may help.

Setting System property from the command line in grails

In one of my recent grails project, I have needed to set System property from the command line while running the grails application. Presumably, we want to set any property, say app.property=”propertyValue”, then the command to set the property in grails application would be:

Similarly to retrieve the value of System property, we use


Another example could be liked this

I found the post on the blog of the developer of Grails core’s ones which is discussing quite a lot of useful tips and tricks for retrieving the application’s properties. The copyright of the featured image comes from that blog.

Hope it helps you to solve your problem.


About Admin

programming all time and taking a bread for the lunch hahaha... When you are engaging your work, nobody can attract you doing another thing. Otherwise, should should move to other jobs or are not interested in your job enough.