Invoke Java method

I have searched to understand how to invoke java code from uipath but unfortunately unable to find any documents or examples. Can someone please explain and share the sample files how to Invoke java method using java scope step by step?

1 Like

hope this would help you

Cheers @subramaniancts

No. I have followed the document but unable to invoke. Any examples will help

here you go with an example

Cheers @subramaniancts

Thanks. I am invoking as per the document but getting exception in Invoke java method activity. i have created a simply method in a class where it will take arguments and print it. I have passed the string parameters as input

RemoteException wrapping System.AggregateException: One or more errors occurred. —> RemoteException wrapping System.InvalidOperationException: The method could not be invoked. —> RemoteException wrapping System.InvalidOperationException: An unexpected exception has occurred during the invocation.
Java Invoker program exception:
java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.uipath.instance.ObjectInstance.InvokeMethod(ObjectInstance.java:141)
at com.uipath.invoker.InvokerContext.invokeStaticMethod(InvokerContext.java:165)
at com.uipath.invoker.InvokerContext.invokeStaticMethod(InvokerContext.java:40)
at com.uipath.server.DotNetProcessRequest.processRequest(DotNetProcessRequest.java:52)
at com.uipath.Main.main(Main.java:46)

at UiPath.Java.Service.JavaResponse.ThrowExceptionIfNeeded()
at UiPath.Java.JavaInvoker.d__17.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at UiPath.Java.JavaInvoker.d__14.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at UiPath.Java.Activities.InvokeJavaMethod.d__16.MoveNext()
— End of inner exception stack trace —
at UiPath.Java.Activities.InvokeJavaMethod.d__16.MoveNext()
— End of inner exception stack trace —
at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context,
IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context,
IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor,
BookmarkManager bookmarkManager)

Can someone please check this and let me know your suggestion?

Hello Palaniyappan,

I have to reuse the java code into my project that have parameter by using Invoke Java Method can i do that or if you have any other solution please suggest.

Need example flow or video that also help.
Thanks in advance …