With Java actions, you can extend the functionality of your application in situations where it would be hard to implement this functionality in microflows.
For information about Java actions in the Modeler, see Java Actions.
2 Writing Code in the .java Files of Your Java Actions
In the java files of your Java actions, you can write your Java code between the markers:
// BEGIN USER CODEand
// END USER CODE
// BEGIN EXTRA CODEand
// END EXTRA CODE
This is explained in more detail below.
The other code in these files is regenerated each time when you deploy your model, thus any modifications that you make in them will be overwritten. However, your imports will be preserved.
A Java action generated by the Mendix Desktop Modeler. This Java action has no input parameters and simply returns a Boolean with value
The method executeAction is called by the Runtime when the Java action is being executed. Between the lines
// BEGIN USER CODE and
// END USER CODE, you can write your custom code that will always be called when executing the action. In this method, you can call other methods in the section between
// BEGIN EXTRA CODE and
// END EXTRA CODE.
The executeAction method throws all exceptions that occur. This means you can do error handling in the microflow calling this Java action. If you would like to do your own error handling within the action, use try/catch statements.
3 Using the Mendix Java library
In the Java code that you write for your Java actions, you can use the Mendix Java library.
You can find the Javadoc at apidocs.mendix.com or in the directory you in which installed Mendix (for example, C:\Program Files\Mendix\7.0.0\runtime\javado).
This library is automatically added to your libraries when you imported your project into Eclipse, and it is called mxruntime.jar.
For details on usage and example, see How to Use the Java API.
4 Using Eclipse as an Environment to Write Your Mendix Java Actions
For details on this topic, see Using Eclipse.
5 Java Actions in the Cloud
For details on this topic, see V3: Java in Mendix Cloud.