How to import external libraries in jshell java 9?
I tried with
9 Build 162 Linux 64-bit with preparation:
The following options are available:
$> CLASSPATH="/opt/libs/commons-lang3-3.4.jar:/opt/libs/guava-19.0.jar" bin/jshell
Specify classpath with jshell option:
$> bin/jshell --class-path /opt/libs/guava-19.0.jar:/opt/libs/commons-lang3-3.4.jar
Configure evaluation context within jshell session with command
/reload(these commands are different, you can check out with its help info), take
jshell> /env -class-path /opt/libs/commons-lang3-3.4.jar:/opt/libs/guava-19.0.jar
And then you're able to either
import org.apache.commons.lang3.StringUtils or
- You can load maven artifacts into JShell through this (modified) version of JShell.
- It also supports /cls command to clear JShell Console. See Maven Example below.
Give a try and share your feedback.