JSHELL(1) JDK Commands JSHELL(1) (NAME) jshell - -- (REPL) ( ) ?[CB]TOOLING?[R] ?[CB]javac?[R] ?[CB]jar?[R] JDK ?[CB]jshell?[R] . " (SYNOPSIS)" jshell [] [-] . jshell . - . JShell . : DEFAULT import . JAVASE Java SE . PRINTING print println printf jshell . . . (startup) . JShell /open . (standard input) I/O (-) - . jshell (pipe chains) . (DESCRIPTION) JShell API . import . (snippet) . . . . (verbose) . JShell . JShell . JShell . . . ?[CB]TOOLING?[R] ?[CB]javac?[R] ?[CB]jar?[R] JDK ?[CB]jshell?[R] . " JSHELL (OPTIONS FOR JSHELL)" --add-exports module/package . --add-modules module[,module...] (resolve) . -Cflag . . --class-path path . CLASSPATH . . macOS (:) . (;) . --enable-preview (preview features) . --execution specification specification ExecutionControl . jdk.jshell.spi . --feedback mode . /set feedback mode . normal . mode : verbose . . (prompt) . normal . . concise . . silent . . custom . JShell /set mode . --help -h -? . --help-extra -X . . -Jflag (runtime system) . . --module-path modulepath . macOS (:) . (;) . --no-startup JShell . JShell JShell . --startup . -q concise --feedback concise . -Rflag (remote runtime system) . . -s silent --feedback silent . --show-version . --startup file . . : DEFAULT import . JAVASE Java SE . PRINTING print println printf jshell . . JShell /reset /reload /env . . --no-startup . -v verbose --feedback verbose . --version . ?[CB]TOOLING?[R] ?[CB]javac?[R] ?[CB]jar?[R] JDK ?[CB]jshell?[R] . " JSHELL (JSHELL COMMANDS)" jshell . /drop {name|id|startID-endID} [{name|id|startID-endID}...] (ID) (drop) . . . /list . /edit [option] . . : {name|id|startID-endID} [{name|id|startID-endID}...] . . . /list . -all . -start JShell . -wait . /set editor . : JSHELLEDITOR VISUAL EDITOR. JShell . /env [options] . . : o . o . o . o (replay) . /drop jshell /open . /reset /env /reload (option) . : --add-modules module[,module...] . --add-exports source-module/package=target-module[,target-module]* package source-module target-module . --class-path path . CLASSPATH . . macOS (:) . (;) . --module-path modulepath . macOS (:) . (;) . /exit [integer-expression-snippet] . . . . /history . /help [command|subject] . . . . subject : context . intro . shortcuts . . /imports JShell . /list [option] . . : {name|id|startID-endID} [{name|id|startID-endID}...] . . . -all . s . e . -start JShell . /methods [option] . . : {name|id|startID-endID} [{name|id|startID-endID}...] . . . /list . -all JShell . -start JShell . /open file . : DEFAULT import . JAVASE Java SE . PRINTING print println printf jshell . ?[CB]TOOLING?[R] ?[CB]javac?[R] ?[CB]jar?[R] JDK ?[CB]jshell?[R] . /reload [options] : o ( ) . o . o . o . /drop jshell /open . /reset /env /reload (option) . : --add-modules module[,module...] . --add-exports source-module/package=target-module[,target-module]* package source-module target-module . --class-path path . CLASSPATH . . macOS (:) . (;) . --module-path modulepath . macOS (:) . (;) . -quiet . . -restore /reset /reload /env . . JShell . /reset [options] : o ( ) . o . o . . . /reset /env /reload (option) . : --add-modules module[,module...] . --add-exports source-module/package=target-module[,target-module]* package source-module target-module . --class-path path . CLASSPATH . . macOS (:) . (;) . --module-path modulepath . macOS (:) . (;) . /save [options] file . . : {name|id|startID-endID} [{name|id|startID-endID}...] . . . /list . -all . -history . -start . . /set [setting] . . . setting : editor [options] [command] /edit . . . : -default JShell . . -delete . -retain : JSHELLEDITOR VISUAL EDITOR. . . -retain . . -wait . JShell . ( ) . . feedback [mode] . . : concise normal silent verbose /set mode. format mode field "format-string" selector . . . . : mode . /set mode . field . JShell /help /set format . "format-string" (selector) . JShell /help /set format . selector . JShell /help /set format . mode [mode-name] [existing-mode] [options] . . . : -command|-quiet . . -command . -quiet . -delete . . -retain . . -retain . . /set prompt /set format /set truncation . /set feedback . prompt mode "prompt-string" "continuation-prompt-string" JShell . . . : mode . /set mode . "prompt-string" . "continuation-prompt-string" . start [-retain] [file [file...]|option] /reset /reload /env . . . : DEFAULT import . JAVASE Java SE . PRINTING print println printf jshell . : -default . -none . -retain . truncation mode length selector . . . : mode . /set mode . length . selector . JShell /help /set truncation . /types [option] enum . enum . : {name|id|startID-endID} [{name|id|startID-endID}...] enum . . . /list . -all enum JShell . -start enum JShell . /vars [option] . . : {name|id|startID-endID} [{name|id|startID-endID}...] . . . /list . -all JShell . -start JShell . /? /help. /! . /{name|id|startID-endID} [{name|id|startID-endID}...] . . . . /list . /-n -n . /-4 . . (INPUT SHORTCUTS) JShell . Tab Tab . . Tab . (signature) . Tab . Tab . Shift+ V . Shift+ M . . Shift+ I . . /l /list . /s /set /save. /se /set /sa /save . . /m -a . . . Ctrl . Ctrl+R . . Ctrl+R . Ctrl+S . (INPUT EDITING) JShell . . Ctrl Meta . Meta Alt Meta . ------------------------------------------------------- Return . . . Ctrl+A . Ctrl+E . Meta+B . Meta+F . Delete . Backspace . Ctrl+K . Meta+D . Ctrl+W . Ctrl+Y . Meta+Y Ctrl+Y . JSHELL (EXAMPLE OF STARTING AND STOPPING A JSHELL SESSION) JShell JDK . jshell . . % jshell | Welcome to JShell -- Version 9 | For an introduction type: /help intro jshell> JShell /list -start . import . s (startup) . jshell> /list -start s1 : import java.io.*; s2 : import java.math.*; s3 : import java.net.*; s4 : import java.nio.file.*; s5 : import java.util.*; s6 : import java.util.concurrent.*; s7 : import java.util.function.*; s8 : import java.util.prefs.*; s9 : import java.util.regex.*; s10 : import java.util.stream.*; jshell> /exit . jshell> /exit | Goodbye % (EXAMPLE OF ENTERING SNIPPETS) import . . . (scratch variable) . jshell> int a=4 a ==> 4 jshell> int b=8 b ==> 8 jshell> int square(int i1) { ...> return i1 * i1; ...> } | created method square(int) jshell> square(b) $5 ==> 64 (EXAMPLE OF CHANGING SNIPPETS) . : jshell> String grade(int testScore) { ...> if (testScore >= 90) { ...> return "Pass"; ...> } ...> return "Fail"; ...> } | created method grade(int) jshell> grade(88) $3 ==> "Fail" grade 80 . if . : jshell> String grade(int testScore) { ...> if (testScore >= 80) { ...> return "Pass"; ...> } ...> return "Fail"; ...> } | modified method grade(int) jshell> grade(88) $5 ==> "Pass" /edit . JShell . . /list 85 . jshell> /edit grade | modified method grade(int) jshell> /list grade 6 : String grade(int testScore) { if (testScore >= 85) { return "Pass"; } return "Fail"; } (EXAMPLE OF CREATING A CUSTOM FEEDBACK MODE) . . . /set mode . mymode normal : jshell> /set mode mymode normal -command | Created new feedback mode: mymode normal . . JShell . . jshell> /set prompt mymode | /set prompt mymode "\njshell> " " ...> " jshell> /set prompt mymode "\nprompt$ " " continue$ " (truncation) . . : jshell> /set truncation mymode 72 jshell> /set truncation mymode 500 varvalue . normal created . defined : jshell> /set format mymode action "defined" added-primary /set feedback . : jshell> /set feedback mymode | Feedback mode: mymode prompt$ int square (int num1){ continue$ return num1*num1; continue$ } | defined method square(int) prompt$ JDK 25.0.4.1 2026 JSHELL(1)