Skip to content

Java "Hello Bot"

This tutorial will guide you through the process of creating a simple Java automation.

Prerequisites

Creating Your First Project

BotCity offers a template project which includes all dependencies, provides scripts and a source code skeleton. A template is available on Github. Just clone the project in the folder you want to have the source code of your bot:

git clone https://github.com/botcity-dev/bot-java-template

This template is a Maven Java project that you can import in any IDE.

Import on Eclipse

If you are using Eclipse, just click on File and Import:

Java Desktop Import

Choose Maven → Existing Maven Projects:

Java Desktop Import Maven

Click on Next

Set the Root Directory to your template bot path, press enter and select /pom.xml:

Java Desktop Import Root

Click on Finish.

Installing the Dependencies

BotCity frameworks are available as Java dependencies in the Nexus repository.

The dependencies will be installed automatically based on the pom.xml configuration.

In the pom.xml of the created project, you will find a configuration similar to this:

<repositories>
    <repository>
        <id>nexus-botcity-public</id>
        <url>https://devtools.botcity.dev:8081/repository/botcity-public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<dependencies>
    <!-- Your other dependencies -->

    <dependency>
        <groupId>dev.botcity</groupId>
        <artifactId>botcity-framework-core</artifactId>
        <version>1.5.0</version>
    </dependency>

    <dependency>
        <groupId>dev.botcity</groupId>
        <artifactId>maestro-sdk</artifactId>
        <version>2.0.3</version>
    </dependency>
</dependencies>

Updating the Project Dependencies

In order to update dependencies recently installed on your local repository, open project menu and select Maven → Update Project:

Java Desktop Maven Update

Exploring the Project

├── LICENSE
├── README.md   <- Simple README file for your bot Project
├── build.bat   <- Batch script to generate the JAR package
├── build.sh    <- Shell script to generate the JAR package
├── pom.xml     <- Maven project file for your bot
└── src
    └── main
        └── java
            └── dev
                └── botcity
                    └── main
                        └── FirstBot.java <- Here is where you will develop
                                             your bot code.

Testing Your Project Locally

FirstBot.java is a bot skeleton providing the basic methods.

Run this class as a Java application and the BotCity website will be opened in your browser.

Here is a screenshot of the expected result: Java Desktop Result

🌟 Excellent 🌟

You are now ready to start creating automations using the BotCity’s Java Framework.

Conclusion

Under this tutorial you learned:

  • The dependencies required to develop automations using BotCity’s Java framework and how to get them installed.

  • How to create new Bot projects using BotCity’s template.

  • How to install and run your new Bot project locally.

Have fun automating 🤖

Next Steps

Now it is time to load your project with BotCity Studio and start creating your automations with Computer Vision and all the productivity offered by our tool.