Creating an imported type for a Java class

The way that a Host On-Demand macro imports a Java™ class is through an imported type. That is, you must first create an imported type and associate it with a particular Java class. You have to do this only once per Java class per macro. Follow these steps to create an imported type:
  1. On the Variables tab, click the Import button. The Import popup window appears.
  2. In the Imported Types list box, select the entry <new imported type>.
  3. Type the Class name for the type, such as java.util.Hashtable. You must type the fully qualified class name, including the package name if any.
  4. Type a Short Name, such as Hashtable. If you do not specify a short name then the AME uses the fully qualified class name as the short name. If you do specify a short name then you can use either the short name or the fully qualified class name when you refer to the imported type.
  5. Click OK.
To create a variable belonging to this imported type, create the variable in the normal way, but select the imported type as the type of the variable. Follow these steps to create a variable of the imported type:
  1. In the Variables list box, click the <new variable> entry at the end. The AME displays the default initial values in the usual way, including a name (such as $a1$), a type (string), and an initial value (blank).
  2. In the Name input field, type the name that you want, such as $ht$.
  3. In the Type list box, select the imported type, such as Hashtable (if you specified a short name when you imported the type) or java.util.Hashtable (if you accepted the default short name, which is the same as the fully qualified class name).
  4. In the Initial Value field, you can either leave the field blank (which results in an initial value of null) or specify a method that returns an instance of the class, such as $new Hashtable()$ (using the short name) or $new java.util.Hashtable()$ (using the fully qualified class name).
Notice that the constructors are enclosed in dollar signs ($). You must use dollar signs around every call to a Java method, just as you must use dollar signs around the name of a variable. (The reason is that the enclosing dollar signs tell the macro runtime that it needs to evaluate the item.)

Going back to the Import popup window, the Imported Types list box allows you to create new types and to edit or delete the types that you have already created. To create a new type, click the <new imported type> entry at the end of the list. To edit a type, select the type in the Imported Types list box and modify the values in the Class and Short Name input fields. To remove a type, select the type and click Remove.

When you specify a short name, you can use any name, with certain restrictions (see Variable names and type names).

For information about creating an imported type in the Source view, see Creating an imported type for a Java class.