# Java Class

This component executes a java class which has execute() method. The java class should be located under custom directory.

![](https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image329.png)

If the execution throws Throwable(Exception), that error is escalated to the caller and that execution is treated as failed. The return value of the method is added to the output data of this component.

## **Input**

&#x20;

<table><thead><tr><th width="216">Attribute</th><th>Description</th></tr></thead><tbody><tr><td>Class name</td><td>Class name with full path - ex) com.xnarum.custom.SampleJava</td></tr><tr><td>Timeout</td><td>Execution timeout in seconds.</td></tr></tbody></table>

&#x20;

## **Output**

&#x20;

<table><thead><tr><th width="216">Attribute</th><th>Description</th></tr></thead><tbody><tr><td>ResultValue</td><td>Return value from the method execution</td></tr></tbody></table>

&#x20;

&#x20;

## **Example**

This example generates a new parameter and return to the caller.

```
package com.xnarum.custom;
                        
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
                        
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
                        
public class SampleJavaClassTask {
                        
    private static Logger logger = LoggerFactory.getLogger(SampleJavaClassTask.class);
    public Map execute(Map map, Properties props) {
                                
        logger.info("Received parameters map = {}, props = {}", map, props);
        HashMap newMap = new HashMap();
        newMap.put("Hello", "world");
        try {
            String timeout = props.getProperty("Timeout");
            Thread.sleep(Integer.parseInt(timeout)*1000);
        }catch( Exception ex ) {
            logger.error("Failed to sleep", ex);
        }
        return newMap; 
    }
}
```


---

# 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://ism-docs.xnarum.com/tasks/others/java-class.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.
