Java Module 2.0 Reference | MuleSoft Documentation
# Java Module 2.0 Reference
Java Module is used to invoke Java code.
Release Notes: Java Module Release Notes
## Configurations
### Default Configuration
Default configuration
#### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
The name for this configuration. Connectors reference the configuration with this name.  
The identifier of this element used to reference it in other components.  
## Operations
  *   * 

### Invoke
`<java:invoke>`
Invoke methods with the provided arguments in an instance. The identifier of the method to invoke includes the class and method names, being the method a full description of its signature including the types of each parameter.
For example, to invoke the `echo` method with the signature `public String echo(String msg)` that belongs to `Class org.bar.Me`, then the identifier of the method is `echo(String)`.
#### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
The instance on which the method is invoked.  
The arguments used to invoke a method. This field must be a map where the keys are the names of the method arguments and the values are the corresponding argument values. For example, if there is a method `echo` with the signature `public String echo(String msg, String volume)`, a possible value for **Args** is `[{ msg : 'This is a message to echo', volume : 'Loud' }]`. To use those argument names, the Java class must be compiled with `-parameters`. If not, you must use the canonical names for the arguments: `[{ arg0 : 'This is a message to echo', arg1 : 'Loud' }]`. You can always use the canonical name for the arguments, even if the source code is compiled with `-parameters`.  
**Output Mime Type** |  MIME type of the payload that this invocation outputs.  
**Output Encoding** |  Encoding of the payload that this invocation outputs.  
Represents the fully qualified name of the class containing the referenced method.  
Represents the method signature containing the method name and its argument types. For example, for the method with signature, `public String log(String msg, boolean verbose)`, then the identifier of the method is `log(String, boolean)`  
**Target Variable** |  The name of a variable in which to place the operation’s output.  
**Target Value** |  An expression to evaluate against the operation’s output, and to store the outcome of that expression in the target variable.  
**Error Mappings** |  Array of Error Mapping |  Set of error mappings.  
#### Throws
  * JAVA:ARGUMENTS_MISMATCH
  * JAVA:CLASS_NOT_FOUND
  * JAVA:INVOCATION
  * JAVA:NO_SUCH_METHOD
  * JAVA:WRONG_INSTANCE_CLASS


### Invoke Static
`<java:invoke-static>`
Operation that allows the user to invoke static methods with the provided arguments. The identifier of the method to be invoked includes the class and method names, being the method a full description of its signature including the types of each parameter.
For example, to invoke the static method `echo` with signature `public static String echo(String msg)` that belongs to `Class org.bar.Me`, then the identifier of the method is `echo(String)`.
#### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
The arguments used to invoke a method. This field must be a map where the keys are the names of the method arguments and the values are the corresponding argument values. For example, if there is a method `echo` with the signature `public String echo(String msg, String volume)`, a possible value for **Args** is `[{ msg : 'This is a message to echo', volume : 'Loud' }]`. To use those argument names, the Java class must be compiled with `-parameters`. If not, you must use the canonical names for the arguments: `[{ arg0 : 'This is a message to echo', arg1 : 'Loud' }]`. You can always use the canonical name for the arguments, even if the source code is compiled with `-parameters`.  
**Output Mime Type** |  MIME type of the payload that this invocation outputs.  
**Output Encoding** |  Encoding of the payload that this invocation outputs.  
Represents the fully qualified name of the Class containing the referenced Method.  
Represents the Method signature containing the method name and its argument types. For example, for the method with signature `public static String log(String msg, boolean verbose)`, then the identifier of the method is `log(String, boolean)`.  
**Target Variable** |  The name of a variable in which to place the operation’s output.  
**Target Value** |  An expression to evaluate against the operation’s output, and to store the outcome of that expression in the target variable.  
**Error Mappings** |  Array of Error Mapping |  Set of error mappings.  
#### Throws
  * JAVA:CLASS_NOT_FOUND
  * JAVA:ARGUMENTS_MISMATCH
  * JAVA:INVOCATION
  * JAVA:NO_SUCH_METHOD


`<java:new>`
Create a new instance of a class.
The identifier of a Constructor includes the class and constructor names, and the constructor has a full description of its signature including the types of each parameter.
For example, to invoke the constructor `Me(String name, int age)` which belongs to the `org.bar.Me` class, then the identifier of the method is `Me(String,int)`.
#### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
The arguments used to invoke the given Constructor  
Represents the fully qualified name of the Class containing the referenced Method.  
**Constructor** |  Represents the Constructor signature that contains the name and its argument types. For example, for the Constructor with the `public Me(String name, Integer age)` signature, then the identifier of the method is `Me(String, Integer)`.  
**Target Variable** |  The name of a variable in which to place the operation’s output.  
**Target Value** |  An expression to evaluate against the operation’s output, and to store the outcome of that expression in the target variable.  
**Error Mappings** |  Array of Error Mapping |  Set of error mappings.  
#### Throws
  * JAVA:ARGUMENTS_MISMATCH
  * JAVA:CLASS_NOT_FOUND
  * JAVA:NO_SUCH_CONSTRUCTOR
  * JAVA:NOT_INSTANTIABLE_TYPE


### Validate Type
`<java:validate-type>`
Validate that an instance is an `instanceof` a class.
#### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
The object whose type is expected to be an instanceof of a class.  
**Accept Subtypes** |  Whether or not to accept subtypes of a class, or if the instance has to be of the exact same class.  
**Error Mappings** |  Array of Error Mapping |  Set of error mappings.  
#### Throws
  * JAVA:CLASS_NOT_FOUND
  * JAVA:WRONG_INSTANCE_CLASS


## Types
### Error Mapping
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
Enumeration, one of:
  * REDELIVERY_EXHAUSTED
  * TRANSFORMATION
  * EXPRESSION
  * SECURITY
  * CLIENT_SECURITY
  * SERVER_SECURITY
  * ROUTING
  * CONNECTIVITY
  * RETRY_EXHAUSTED
  * TIMEOUT

| Source of the error mapping.  
Target of the error mapping.  
## See Also
MuleSoft Help Center