JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Defining Constants and Variables for Oracle Java CAPS Environments     Java CAPS Documentation
search filter icon
search icon

Document Information

Defining Constants and Variables

Defining Project Variables

Defining Project Constants

Defining Environmental Constants

Defining Project Constants

Figure 4 Constant or Variable Icon

image:Image of a Constant or Variable Icon

Project constants are name-value pairs that are visible across the Project. Using a constant allows you to define the value once, and then refer to it from the various Project configurations, rather than having to redefine the value everywhere it is needed. For example, the following figure shows a standard currency defined to be used globally throughout the system.

You can add a constant to a Project by selecting the New > Variable or Constant option from the Project context menu in the NetBeans IDE, which displays the following dialog box.

Figure 5 Creating a Project Constant

image:Screen capture showing the Project Constant creation dialog box.

Table 3 Project Constant Options

Property
Option
Description/Usage
Name
Your name for the Project constant.
Category
You may assign a category name, if desired.
Description
Your description for the constant.
Is a Constant
Select to enable the constant properties fields.
Value Type
String
Allows the string value to be displayed explicitly.
Password
Encrypts the value, displaying asterisks (*) in the field.
Value
The value for the constant.

Constants and variables are automatically added to a Variables and Constants object group within the Project, as shown in the following figure. Selecting an entry in the upper panel displays it in the lower panel, where you can modify it. By clicking OK you overwrite the previous definition with the modified version.

Figure 6 Variables and Constants Object Group

image:Screen capture showing the Variables and Constants Object Group user interface.

Table 4 Constants and Variables Object Group Icons

Icon
Name
Function
image:Image of Add Constant or Variable Icon.
Add a New Constant or Variable
Adds a new constant to the list.
image:Image of Delete Constant or Variable Icon.
Delete a Highlighted Constant or Variable
Deletes the selected constant from the list.