+44(0)1908 545 770
YOUR EXPERT RPA PARTNER

Team up with our RPA strategy and tech specialists for maximum automation impact

Find out more
Harness the power of UiPath in your business.
WATCH NOW

Save money and spend more time on priority work.

Book consultation
READY, SET, AUTOMATE

Let's choose, design and deploy a process automation solution for your business.

Find out more
TRANSFORM YOUR BUSINESS

Let's analyse your business to discover opportunities for innovation and automation.

Find out more

Begin your business transformation journey

Book consultation
AUTOMATE EVERY FUNCTION

Automate where it matters most. Scale to solve challenges in every area

Find out more
GIVE EVERY TEAM THE TOOLS FOR SUCCESS

Equip people with user-friendly solutions that save time and make work easier

Find out more

Which business problem
can we solve first?

Book consultation
28 March 2019

Custom Java Actions in Mendix

There is no direct way in Mendix where we can call Java code.  To include any custom Java code, we can use Java Actions.  This article will cover the steps on how to add and make use of a Java Action. We will be using simple Java program for different mathematical calculation operations – for example, Add, Subtract and Multiply.

Step 01

Create a page to input two integer variables and select mathematical operation to be done.

Custom Java in Mendix Step 1 Custom Java in Mendix – Step 1

Step 02

Let’s create a Java Action to execute our Java code which will be executed through a microflow on click of Calculate Button.

Right click on the module Math Operation, click on add other and select Java Action. Name Java Action as MathOperation

Custom Java in Mendix - Step 2 Custom Java in Mendix – Step 2

Step 03

Configure the Java Action

a) Add Parameters under the general tab:

Custom Java in Mendix - Step 3 Custom Java in Mendix – Step 3

b) Check ‘expose as microflow action’ under Expose as microflow action tab in order use the Java Action in microflow:

Custom Java in Mendix - Step 3

You can get more in-depth on Java Action properties information HERE

Step 04

The Java Action created should be available under the created category in Toolbox bar.

The next step is to execute the Java Action using microflow. Let’s create a microflow:

Custom Java in Mendix - Step 4 Custom Java in Mendix – Step 4 (a)

Add an Action activity to call the Java Action and map the parameters and result.

Custom Java in Mendix - Step 4

Step 05

In order to proceed with further steps, we need to install eclipse to write our custom Java code.


Download Eclipse…

Step 06

Deploy the solution for Eclipse by clicking on the ‘Deploy for Eclipse’ under project:

Custom Java in Mendix - Step 6

Step 07

Click on Show project directory in explorer:

Custom Java in Mendix - Step 7 Custom Java in Mendix – Step 7 (1)

Import the project in Eclipse…

Custom Java in Mendix - Step 8 Custom Java in Mendix – Step 7 (2)

Go to Java file under mathoperation. Actions:

Custom Java in Mendix - Step 8 Custom Java in Mendix – Step 7 (3)

Step 08

Locate the placeholder with commented statements (Begin user code and end user code):

Custom Java in Mendix - Step 8 Custom Java in Mendix – Step 8 (1)

You can write your java code here. The modeller will never override your code placed between these two commented statements.

Once done, run the project from modeller and try executing your code from screen:

Custom Java in Mendix - Step 8 Custom Java in Mendix – Step 8 (2)

Need further technical advice or support?