Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Environment variable

 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to be able to check an environment variable in my Java code. Apparently you can't do this. If I set system properties in a WSAD test environment, I can simply use System.getProperty("PROPERTY NAME"); and it works perfectly. I cannot seem to find where in the admin console of WAS 5 I put this setting. I have tried in "custom properties" and that doesn't seem to work. How can I get this environment variable functionality?
 
Rufus BugleWeed
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in a web project -
<!--
The context-param element contains the declaration of a web
application's servlet context initialization parameters.
Used in: web-app
-->
<!ELEMENT context-param (param-name, param-value, description?)>
in an ejb project -
<!--
The env-entry element contains the declaration of an enterprise bean's
environment entry. The declaration consists of an optional
description, the name of the environment entry, and an optional
value. If a value is not specified, one must be supplied
during deployment.
Used in: entity, message-driven, session
-->
<!ELEMENT env-entry (description?, env-entry-name, env-entry-type,
env-entry-value?)>
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you mean System environment variables (not application environment variables, which is what rufus is suggesting) then you do this by modifying the JVM settings in your Server configuration and adding JVM parameters.
Kyle
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I wanted a setting in the app server that I could just switch to change a few settings (i.e. cookie decryption key, data source gateway I.P.) on the fly. This is an app only used by our customers, that we don't sell and resides on one server. Anyhow, my boss wanted me to find a way outside of the web.xml method so that we could just take the EAR file and put it on a development server, turn the switch and we're off using a different environments settings. Anyhow it took me a while to find the JVM settings in WAS 5. It was a royal pain in the butt for me. For those that care, you need to go the application server -> process definition -> Java Virtual Machine -> and under Additonal properties at the bottom there is a link for 'custom properties'. Enter your value/name pair there. In your code you simply use System.getProperty("PROPERTY_NAME"); to read the value. It works great now. Thanks for the input guys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic