wood burning stoves*
The moose likes Websphere and the fly likes Environment variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Environment variable" Watch "Environment variable" New topic
Author

Environment variable

Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
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

Joined: Feb 22, 2002
Posts: 1551
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

Joined: Aug 10, 2001
Posts: 3892
    
    5
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


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Environment variable