This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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?
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?)>
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
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.