There is a section in the WebSphere Admin console called WebSphere variables (located under Environment), where you can … manage WebSphere variables (WAS variables). But how can one use these WAS variables within a JavaEE application? There is a proprietary way to load them which I will not mention here.

A better way in my opinion is to bridge the WAS variable to an environment variable. Then it can simply be accessed through System.getProperty(“varName”); It’s also easy to access the variable on Tomcat without touching the code.

To bridge a WAS variable:

  1. Log on to your WAS console.
  2. Add a WAS variable “myapp.myVar” under Environment -> WebSphere variables
  3. Go to (something like) Servers -> Server Types -> Websphere application servers -> YOUR_SERVER -> Java and process management -> Process definition -> Java virtual machine -> Custmo properties
  4. Define a new variable myapp.myVar = ${myapp.myVar}
  5. Save and restart.

The value of myapp.myVar can now be obtained: System.getProperty(“myapp.myVar”)