Note that this example uses sdkman.
CP=$(mktemp) && \
mvn dependency:build-classpath -Dmdep.includeScope=compile -Dmdep.outputFile=$CP -q -f ./pom.xml && \
CP=$(cat $CP) && \
$(sdk home java 11.0.8.hs-adpt)/bin/jshell --class-path $CP
CP=$(mktemp) && \
mvn dependency:build-classpath -Dmdep.includeScope=compile -Dmdep.outputFile=$CP -q -f ./pom.xml && \
CP=$(cat $CP) && \
$(sdk home java 11.0.8.hs-adpt)/bin/jshell --class-path $CP
| Welcome to JShell -- Version 11.0.8
| For an introduction type: /help intro
jshell>
$CP = (New-TemporaryFile).FullName; `
mvn dependency:build-classpath "-Dmdep.includeScope=compile" "-Dmdep.outputFile=$CP" -q -f ./pom.xml; `
$CP = Get-Content $CP -Raw; `
& "C:/Program` Files/OpenJDK/jdk-11/bin/jshell" --class-path $CP
> $CP = (New-TemporaryFile).FullName; `
>> mvn dependency:build-classpath "-Dmdep.includeScope=compile" "-Dmdep.outputFile=$CP" -q -f ./pom.xml; `
>> $CP = Get-Content $CP -Raw; `
>> & "C:/Program` Files/OpenJDK/jdk-11/bin/jshell" --class-path $CP
| Welcome to JShell -- Version 11.0.2
| For an introduction type: /help intro
jshell>
@mehiel pointed me to the jshell-maven plugin, which makes the above easier :)
Note that this requires JDK 11+!