# Java Task

The **Java Task** is used to invoke and execute **custom Java code** within a business process.\
It allows developers to extend process behavior by calling Java methods packaged in external **JAR files**.

The Java Task is represented by a **rectangular BPMN activity node**, as shown below.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2Fa7Eu263x89Duy6xqfNlG%2F0?alt=media" alt=""><figcaption></figcaption></figure>

***

### Purpose

The **Java Task** is designed to support **custom logic execution** that cannot be easily achieved using standard process activities.

Typical use cases include:

* Complex business logic
* Custom calculations
* Data transformation
* Integration logic not covered by Web Service or Database tasks
* Reusable utility functions

To use a Java Task, users must:

1. Implement Java methods
2. Package them into a **JAR file**
3. Upload the JAR file into the Java Task
4. Select and execute the required method at runtime

Any JAR file containing eligible Java classes and methods can be used by the Java Task.

***

### Java Task Configuration Overview

The Java Task configuration panel consists of **three main tabs**:

1. **General**
2. **Business Object**
3. **Java Parameter**

Each tab defines a different aspect of task execution.

***

### General Tab

The **General** tab contains basic metadata for the Java Task, including:

* Task name
* Task ID
* Description

These values are used for identification and documentation within the process flow.

> **Important**\
> Always click **Save Panel** to persist configuration changes.

***

### Business Object Tab

The **Business Object** tab is used to configure and map:

* **Input parameters** passed into the Java method
* **Output parameters** returned from the Java method

This mapping enables:

* Passing process data to Java code
* Using Java execution results in subsequent activities

Business Object mapping is required if:

* The Java method consumes process data
* The Java method produces output values needed later in the process

***

### Java Parameter Tab

The **Java Parameter** tab is used to define **which Java code is executed**.

<figure><img src="https://2015371994-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMpDjHWFRUtZ5nJcSfVXd%2Fuploads%2FiVnbKqQEU5hPcvuu50gC%2F1?alt=media" alt=""><figcaption></figcaption></figure>

#### Java Parameter Properties

| Property    | Mandatory | Description                                                                                                    |
| ----------- | --------- | -------------------------------------------------------------------------------------------------------------- |
| Jar Name    | Yes       | The JAR file containing the Java classes. Can be uploaded using **Choose Jar** or selected from existing JARs. |
| Class Name  | Yes       | Fully qualified class name. Retrieved automatically using **Get Class Name** after selecting the JAR file.     |
| Method Name | Yes       | Java method to be executed. The system lists all eligible methods from the selected class.                     |

#### Java Parameter Actions

* **Choose Jar**\
  Upload a new JAR file containing Java code
* **Get Class Name**\
  Retrieve all available classes from the selected JAR file
* **Method Selection**\
  Select the method to be executed from the available list

***

### Best Practices

* Keep Java methods **stateless** and reusable
* Clearly define input and output parameters
* Handle exceptions within Java code properly
* Avoid embedding heavy business logic that is better modeled in BPMN
* Version JAR files carefully to avoid breaking processes

***

### Summary

The **Java Task** enables deep extensibility of ONEWEB processes through custom Java execution.

Key points:

* Executes user‑defined Java methods from external JAR files
* Supports input and output parameter mapping
* Enables complex or reusable logic integration
* Works seamlessly within BPMN process flows
* Ideal for advanced or technical use cases

The Java Task is a powerful option when process behavior must go beyond standard activity capabilities while remaining fully integrated within **Process Designer**.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onewebstack.com/oneweb-platform-th/designer-reference/process-designer/process-designer-component/activity-nodes/java-task.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
