Define environment variables
Environment variables are constant variables that you can define in EJB modules.
For example, if you define a Circle bean, you could create an environment variable called PI and set the value to 3.1415926. If you had another enterprise bean or servlet called Cone, it could access the PI variable by doing a JNDI lookup.
To add an environment variable to an enterprise bean:
- In the Project Explorer view of the J2EE perspective, right-click the Deployment Descriptor for your EJB project and select Open With > Deployment Descriptor Editor to open the deployment descriptor editor.
- On the Bean page of the editor, scroll to the Environment Variables section and click Add. The Add Environment Variables wizard appears.
- Type a Name for the new variable.
- Select a data Type from the following choices:
- String
- Integer
- Boolean
- Double
- Byte
- Short
- Long
- Float
- Type a value for the new variable in the Value field. The value depends on the type of variable that you are creating.
- Click Finish.
The new environment variable is added and displayed in the Environment Variables section of the deployment descriptor editor.
- To edit the environment variable, select it from the list and click Edit.
- To delete the environment variable, click Remove.
- To see the XML entry for the environment variable in the deployment descriptor, double-click the variable.
Related concepts
EJB Deployment Descriptor editor