Invoke java method and pass two arguments from uipath

Hi experts,

I have a scenario where I need to pass two or more parameter from UiPath and do basic calculations like add or subtract. But I am stuck here -
how can I send uipath input variable value to Java code method, do the neccessary calculations and print it in uipath “Message Box”.
Any answers would be of great help.


Hello @sowmya.krishna

You can use Invoke Java method activity to achieve this. In your java script use a return statement to return the sum output and then you will get the value to the output variable of invoke java method activity.

Then you can print that in a message box.

Hi @Rahul_Unnikrishnan
how to pass parameters in the Invoke Java method activity. Can you provide me a sample code for the same.

Hello @sowmya.krishna ,

iI created a Java project and converted that to jar file. Java script you can see below also the workflow.

You can do as below.


Below is the Java code.

hi @Rahul_Unnikrishnan

I tried the same workflow but getting error in Invoke Java Method, “Invoke Java Method: One or more errors occurred.”

@sowmya.krishna Did you update with your jar file and did you modified the function name in it?

Because the workflow which I shared was refering to the jar file in my system

Hi @Rahul_Unnikrishnan
Yes I have updated jar file and modified the function name in it.

@sowmya.krishna Share the error which you have received?

@Rahul_Unnikrishnan “Invoke Java Method: One or more errors occurred.”

@sowmya.krishna it shows some configuration issue

Can you share the screenshot of the workflow here… Also share the screenshot of function which you are calling




In the load jar activity did you provided the java path?? Also for the jar file could you provide the full path and check once

@Rahul_Unnikrishnan Yeah I have provided completed path for load jar activity

@sowmya.krishna Did you used Java Scope and provided the Java path. You can go to Environment Variables in your machine and get the Java path. You have to provide all the activities inside that path. Please confirm whether you did that or not

I have used Java scope activity and used all activities inside that. Earlier I didnt give the java path. I tried giving now but getting error as “Java Scope: The path to java library is invalid.
Parameter name: JavaLibraryPath”
But the path is correct. Dnt knw why its throwing error

@sowmya.krishna plz share the screenshot of that path in Java scope.

@Rahul_Unnikrishnan pls check

@sowmya.krishna You can remove \Java.exe

@Rahul_Unnikrishnan I tried that also but same error

it seems the path which you provided is wrong. Check in *C:\Program Files\Java*

There you will able to see a folder with the java version, somewhat like jdk-17.0.2

open command prompt and type echo %JAVA_HOME%