JDK 11 provides the Java API for creating tools such as jshell for evaluating Java code snippets. This Java API is present in the jdk.jshell module (http://cr.openjdk.java.net/~rfield/arch/doc/jdk/jshell/package-summary.html). So, if you want to use the API in your application, you need to declare a dependency on the jdk.jshell module.
In this recipe, we will use the JShell JDK API to evaluate simple code snippets, and you'll also see different APIs to get the state of JShell. The idea is not to recreate JShell but to show how to make use of its JDK API.
For this recipe, we will not be using JShell; instead, we will follow the usual way of compiling using javac and running using java.