How to Use JShell (Java REPL) in Combination with UiPath

Since Release SE 9 Java offers the JShell, a Java read-eval-print-loop (REPL) tool to interactively evaluate Java declarations, statements and expressions. But JShell offers more as try out code and explore Java language options. Also you can load a JShell script file, which is a sequence of snippets and JShell commands, which is executed by JShell.

This means that we can execute Java command sequences as script. This integration scenario offers us the advantage that we do not have to deliver binary files, such as JAR or Class, but we can deliver the source code here. To realize a smart integration of JShell into UiPath I have developed an activity.

JShell.Activities.1.0.1.nupkg (6.8 KB)

After installing the package you can find the “Invoke JShell File” item in the Programming > JShell path. Also it is necessary to install the OpenJDK and to set the JAVA_HOME variable, if you like, otherwise you have to set the path in the option JShellPath.


With this it is possible to use JShell scripts.



Here a tiny example which reads the input arguments and delivers it back.


String arg1 = System.getProperty("arg1");

String arg2 = System.getProperty("arg2");




On this way we can seamlessly execute Java source code as JShell script into UiPath. It is not necessary to compile the source code. For certain use cases this can be very advantageous.

You can find the JShell User Guide here.

For a better deployment it is possible to build an individual NuGet package which contains the OpenJDK.

On this way it is possible to use the OpenJDK direct in the context of the UiPath project.


Additional, to ensure that the standard environment variable JAVA_HOME is set correctly, here a tiny snippet to handle this.

//-UiPath Begin---------------------------------------------------------

try {

  JAVA_HOME = Environment.GetEnvironmentVariable("JAVA_HOME");
  if(String.IsNullOrEmpty(JAVA_HOME)) {
    string UserProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
    string JDKPath = UserProfile + "\\.nuget\\packages\\openjdk\\16.0.1";
    Environment.SetEnvironmentVariable("JAVA_HOME", JDKPath);
    JAVA_HOME = Environment.GetEnvironmentVariable("JAVA_HOME");

} catch (Exception e) {

//-UiPath End-----------------------------------------------------------


With all these steps is the integration of Java language in an UiPath workflow easier possible.

You can find an example how to use Java Selenium, based on this approach, here.