Read and Review Automation Anywhere Documentation

Automation 360

Close Contents


Open Contents

Create and build a custom package using IntelliJ

  • Updated: 2021/04/05
    • Automation 360 v.x
    • Build
    • RPA Workspace

Create and build a custom package using IntelliJ

Use Java IntelliJ to compile a JAR file that you can upload as a package to your Control Room in Automation 360.


A basic understanding of JDK and Java IntelliJ is required in order to build an action package. Ensure the following software and files:


  1. Unzip the contents of the SDK package to your IdeaProjects directory and rename the folder from A2019-package-sdk-<version number> to MetricToImperial.
    By default, the package is located at: C:\Users\<User>\IdeaProjects.
  2. In IntelliJ IDEA, go to File > Open and open the project at C:\Users\<User>\IdeaProjects\MetricToImperial.
  3. Open the settings.gradle file in the project root. Set the = 'MetricToImperial'
  4. Update the package.template file located at src > main > resources > package.template.
  5. Change the package name from A2019DemoPackage to MetricToImperial.
  6. Update the package name in locales json: go to src > main > resources > locales > en_US.json.
    1. Open the en_US.json file and update the required label field from A2019DemoPackage to MetricToImperial. Update the optional description.
    2. Delete all other remaining lines in the en_US.json file.
  7. Create a new Java Class, right-click the metrictoimperial.commands package, and select New > Java Class. Enter the name for the new class CMtoINCH:
    1. Open the CMtoINCH class. Copy and paste the following code above the class definition statement:
      import static com.automationanywhere.commandsdk.model.DataType.NUMBER;
      //BotCommand makes a class eligible for being considered as an action.
      //CommandPks adds required information to be dispalable on GUI.
              //Unique name inside a package and label to display.
              name = "CM to Inch", label = "[[CMtoINCH.label]]",
              node_label = "[[CMtoINCH.node_label]]",  description = "[[CMtoINCH.description]]", icon = "ruler_icon.svg",
              //Return type information. return_type ensures only the right kind of variable is provided on the UI.
              return_label = "[[CMtoINCH.return_label]]", return_type = NUMBER, return_required = true)
    2. Inside the CMtoINCH class, copy and paste the following code:
    //Identify the entry point for the action. Returns a Value<String> because the return type is String.
    public NumberValue action(
            //Idx 1 would be displayed first, with a text box for entering the value.
            @Idx(index = "1", type = AttributeType.NUMBER)
            //UI labels.
            @Pkg(label = "[[CMtoINCH.CMInput.label]]")
            //Ensure that a validation error is thrown when the value is null.
                    Double CMInput) {
        //Internal validation, to disallow empty inputs. No null check needed as we have NotEmpty on CMInput.
        if ("".equals(CMInput.toString().trim()))
            throw new BotCommandException("Input of CM is required");
        Number result;
        try {
            //Conversion logic
            result = CMInput * 0.393701;
        } catch (Exception e) {
            //Throw custom error message
            throw new BotCommandException("Unable to convert " + CMInput.toString() + "cm to inches");
        //Return NumberValue.
        return new NumberValue(result);
    The code automatically imports namespaces based on the annotations and datatypes.

    To manually import namespaces, select a highlighted line, and press these keys simultaneously alt and the enter key.

  8. Configure en_US.json file, go to src > main > resources > locales > en_US.json and add the following fields after the label and description values:
    "CMtoINCH.label" : "cm to inches",
    "CMtoINCH.node_label": "cm to inches",
    "CMtoINCH.description" : "Convert centimeters to inches",
    "CMtoINCH.return_label" : "Assign the Output in Inches to a Number Variable",
    "CMtoINCH.CMInput.label" : "Centimeters to Convert to Inches"
  9. Delete the sample packages, go to src > main > java > com.automationanyhwere.botcommand, and delete the samples.commands and delete the samples packages.
  10. Update the CommandPkg annotation. Download icons from Github.
    1. Download ruler_icon.svg from github and right-click the image and save the image as ruler_icon.svg.
    2. Download iconwhite.svg from github, right-click the image and save the image iconwhite.svg.
    3. Copy both files into the src > main > resources > icons folder.
  11. Open the build.gradle in the project root. After the dependencies section, but before the last closing tag, copy and paste the following code:
    test {
       testLogging {
          exceptionFormat = 'full'
       useTestNG() {}
       afterSuite { desc, result ->
          if (!desc.parent)
             println("${result.resultType} " +
                   "(${result.testCount} tests, " +
                   "${result.successfulTestCount} successes, " +
                   "${result.failedTestCount} failures, " +
                   "${result.skippedTestCount} skipped)")
       maxHeapSize "3g"
  12. Create a new directory, right-click src and select New > Directory.
    1. In the Name field, enter test\java, or select the test\java suggestion from the Gradle Source Sets.
    2. Create a new package, right-click the java directory and select New > Package.
    3. Enter the name for the newly created package: com.automationanywhere.botcommand.metrictoimperial.commands.
  13. Create new Java class, right-click and select New > Java Class. Enter the name for the new class CMtoINCHTest.
    Inside the CMtoINCHTest class, copy and paste the following code:
    public void testCMtoINCH(){
        Double validInput = 10.00;
        Double expectedOutput = 0.393701 * validInput;
        CMtoINCH testCM = new CMtoINCH();
        Value<Double> result = testCM.action(validInput);
        Assert.assertEquals(result.get(), expectedOutput);
  14. Save the project File > Save All.
  15. Build the package.
    You can use the IntelliJ UI or the command line. If you are using the command line:
    1. Open a terminal window and navigate to the MetricToImperial directory and enter: cd "%USERPROFILE%\IdeaProjects\MetricToImperial"
    2. To build the project, enter the following command: gradlew.bat clean build shadowJar
    A BUILD SUCCESSFUL message appears.

    Sometimes a build might fail because existing files could not be automatically deleted and a system message appears indicating the execution failed for the task: clean. If this occurs, close the explorer windows and run the build again.

Next steps

Add custom package to your Control Room
Send Feedback