Defining environment variables

Environment variables are constant variables that you can define in EJB modules. You can add an environment variable to an enterprise bean

About this task

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.

Procedure

  1. In the Enterprise Explorer view of the Java™ EE perspective, right-click the deployment descriptor for your EJB project and select Open With > Deployment Descriptor Editor.
  2. On the Bean page of the editor, scroll to the Environment Variables section and click Add.
  3. Type a Name and Description for the new variable.
  4. Select a data Type from the following choices:
    • String
    • Integer
    • Boolean
    • Double
    • Byte
    • Short
    • Long
    • Float
  5. Type a value for the new variable in the Value field. The value depends on the type of variable that you are creating.
  6. Click Finish.

Results

The new environment variable is added and displayed in the Environment Variables section of the deployment descriptor editor.

What to do next

You can also perform the following actions on variables you have created:


Feedback