Reference articles on history, science, culture and more
Encyclopedia

JShell

JShell is a Java read-eval-print loop which was first introduced in the JDK 9. It is tracked by JEP 222 jshell: The Java Shell (Read-Eval-Print Loop). One reason why JShell was proposed for Java 9 is the lack of a standard interactive environment for the language; the de facto library to use a Java REPL was often BeanShell, which has been dormant since 2003, and arbitrarily diverged from the Java language.

01Example

jshell> int a[] = { 0, 1, 3, 5, 8 } a ==> int[5] { 0, 1, 3, 5, 8 } jshell> int fact(int n) { ...> return n < 2 ? 1 : n * fact(n - 1); ...> } | created method fact(int) jshell> for (int i = 0; i < a.length; ++i) ...> a[i] = fact(a[i]); jshell> a a ==> int[5] { 1, 1, 6, 120, 40320 }
Watch videos about JShellExplainers and documentaries on YouTube (opens in a new tab)

Sources and credits

This article is adapted from the Wikipedia article JShell, written by its contributors and licensed under CC BY-SA 4.0. Fathomly has changed the layout, removed citation markers, navigation and maintenance notices, and adjusted punctuation. This adapted version is shared under the same license. For references, see the original article.

Fathomly is not affiliated with or endorsed by the Wikimedia Foundation. Spotted a problem? Tell us.