Cloud Zone is brought to you in partnership with:

Hi all, my name is Hubert A. Klein Ikkink. Not a very common name, right? To make things easier I just picked the first letters of my firstname and surname and came up with haki. So there you have it, now I am also known as Mr. Haki or mrhaki for short. You can read more blog postings at www.mrhaki.com. I am a passionate Groovy and Java developer based in Tilburg, The Netherlands. My goal is to write clean, elegant, user-centered and high quality software. You can find me on Google+ and Twitter. Hubert is a DZone MVB and is not an employee of DZone and has posted 162 posts at DZone. You can read more from them at their website. View Full User Profile

How to Set Environment Variables for a CloudFoundry App

07.02.2012
| 3560 views |
  • submit to reddit

We can set environment variables for an application that is deployed in CloudFoundry. For example if we want to pass a JAVA_OPTS environment variable with a value of -XX:MaxPermSize=256m. We have to use the env-add command of the vmc command-line tool. We specify the application name we want to set the environment variable for followed by a key=value pair.

In the following command we set a JAVA_OPTS environment variable for the website application:

$ vmc env-add website JAVA_OPTS="-XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled"
Adding Environment Variable [JAVA_OPTS="-XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled"]: OK
Stopping Application: OK
Staging Application: OK
Starting Application: OK
$

To see which environment variables are set we can use the env command. To delete a variable we use env-del and the name of the environment variable.

$ vmc env website
 
+-----------+----------------------------------------------------+
| Variable  | Value                                              |
+-----------+----------------------------------------------------+
| JAVA_OPTS | -XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled |
+-----------+----------------------------------------------------+
 
$ vmc env-del website JAVA_OPTS
Deleting Environment Variable [BLOG_OPTS]: OK
Stopping Application: OK
Staging Application: OK
Starting Application: OK
$

 

 

Published at DZone with permission of Hubert Klein Ikkink, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)