JSHELL(1) JDK Commands JSHELL(1) (NAME) jshell - Java -- (REPL) (SYNOPSIS) jshell [options] [load-files] options . jshell . load-files . JShell . : DEFAULT import . JAVASE Java SE (import) . PRINTING print println printf jshell . TOOLING javac jar JDK jshell . . . (startup) . JShell /open . (standard input) / (-) load-files . jshell (pipe) . (DESCRIPTION) JShell Java API . Java import . (snippet) . . . . (verbose) . JShell . JShell . JShell . . . JSHELL (OPTIONS FOR JSHELL) --add-exports module/package . --add-modules module[,module...] . -Cflag flag Java JShell . -C-Xlint lint -C--release= Java SE N --release N . --class-path path . CLASSPATH (override) . . Linux macOS (:) . Windows (;) . --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 flag . -Rflag . -Jflag --execution local . --module-path modulepath . Linux macOS (:) . Windows (;) . --no-startup JShell . JShell JShell . --startup . -q concise --feedback concise . -Rflag flag . -R-Dfoo=bar System.getProperty("foo") "bar" . -s silent --feedback silent . --show-version . --startup file (override) . . : DEFAULT import . JAVASE Java SE (import) . PRINTING print println printf jshell ..TP TOOLING javac jar JDK jshell . . JShell /reset /reload /env . . --no-startup . -v verbose --feedback verbose . --version . JSHELL (JSHELL COMMANDS) jshell . /drop {name|id|startID-endID} [{name|id|startID-endID}...] . . . /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 ( ) . /drop jshell /open . /reset /env /reload option . : --add-modules module[,module...] (resolve) . --add-exports source-module/package=target-module[,target-module]* package source-module target-module . --class-path path . CLASSPATH . . Linux macOS (:) . Windows (;) . --module-path modulepath . Linux macOS (:) . Windows (;) . /exit [integer-expression-snippet] . . . . /history . /help [command|subject] . . . . subject : context . intro . shortcuts . Input 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 (import) . PRINTING print println printf jshell . TOOLING javac jar JDK jshell . /reload [options] : o ( ) . o . o . o . /drop jshell /open . /reset /env /reload . : --add-modules module[,module...] . --add-exports source-module/package=target-module[,target-module]* (export) package source-module target-module . --class-path path . CLASSPATH (override) . . Linux macOS (:) . Windows (;) . --module-path modulepath . Linux macOS (:) . Windows (;) . -quiet . . -restore /reset /reload /env . . JShell . /reset [options] : o ( ) . o . o . . . /reset /env /reload . : --add-modules module[,module...] . --add-exports source-module/package=target-module[,target-module]* (export) package source-module target-module . --class-path path . CLASSPATH (override) . . Linux macOS (:) . Windows (;) . --module-path modulepath . Linux macOS (:) . Windows (;) . /save [options] file . . : {name|id|startID-endID} [{name|id|startID-endID}...] (ID) . . (space) . /list . -all . -history . -start . . /set [setting] (feedback mode) . (prompt) . 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 (context) . JShell /help /set format . mode [mode-name] [existing-mode] [options] . (prompt) (truncation) . . : -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 . TOOLING javac jar JDK jshell . : -default . -none . -retain . truncation mode length selector . . . : mode . /set mode . length . selector . JShell /help /set truncation . /types [option] (interfaces) 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. /! (snippet) . /{name|id|startID-endID} [{name|id|startID-endID}...] (ID) . . (space) . . /list . /-n -n . /-4 . . (INPUT SHORTCUTS) JShell . Tab (Tab completion) Tab . . Tab . (signature) . Tab . Tab . Shift+ V (expression) (variable declaration) . Shift+ M (statement) (method declaration) . . Shift+ I (identifier) import class path . (Command abbreviations) . /l /list . /s /set /save. /se /set /sa /save . . /m -a . (History navigation) (sessions) . . Ctrl . (History search) Ctrl+R . (prompt) . Ctrl+R . Ctrl+S . (INPUT EDITING) JShell . . Ctrl Meta . Meta Alt Meta . ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Return . Left arrow . Right arrow . Ctrl+A . Ctrl+E . Meta+B . Meta+F . Delete . Backspace . Ctrl+K . Meta+D . Ctrl+W (white space) . 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 . (ID) 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 (expressions) . . . (scratch) . 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) . . 72 500 : jshell> /set truncation mymode 72 jshell> /set truncation mymode 500 varvalue (format) . 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 26.0.2.1 2026 JSHELL(1)