jshell - What Is It

This section describes what is 'jshell' - a command line tool that allows you to interactively evaluates declarations, statements, and expressions.

What Is "jshell"? - "jshell" is a command line tool that allows you to interactively evaluates declarations, statements, and expressions of the Java programming language in a Read-Eval-Print Loop (REPL).

"jshell" has been included in JDK installation since JDK 9. And it is represented by the %java_home%\bin\jshell.exe program file.

"jshell" provides you an environment where you can use Java as a scripting language. With "jshell", you can:

If you have %java_home%\bin directory included in "path" the environment variable, you can run "jshell --help" to get the usage information:

herong> jshell --help

Usage:   jshell <option>... <load-file>...
where possible options include:
    --class-path <path>   Specify where to find user class files
    --module-path <path>  Specify where to find application modules
    --add-modules <module>(,<module>)*
        Specify modules to resolve, or all modules on the
        module path if <module> is ALL-MODULE-PATHs
    --startup <file>      One run replacement for the startup definitions
    --no-startup          Do not run the startup definitions
    --feedback <mode>
        Specify the initial feedback mode. The mode may be
        predefined (silent, concise, normal, or verbose) or
        previously user-defined
    -q                    Quiet feedback.  Same as: --feedback concise
    -s                    Really quiet feedback.
    -v                    Verbose feedback.  Same as: --feedback verbose
    -J<flag>              Pass <flag> directly to the runtime system.
        Use one -J for each runtime flag or flag argument
    -R<flag>              Pass <flag> to the remote runtime system.
        Use one -R for each remote flag or flag argument
    -C<flag>              Pass <flag> to the compiler.
        Use one -C for each compiler flag or flag argument
    --version             Print version information and exit
    --show-version        Print version information and continue
    --help                Print this synopsis of standard options and exit
    --help-extra, -X      Print help on non-standard options and exit

A file argument may be a file name, or one of the predefined file names:
DEFAULT, PRINTING, or JAVASE.

A load-file may also be "-" to indicate standard input, without
interactive I/O.

For more information on the evaluation context options (--class-path,
--module-path, and --add-modules) see:
  /help context

A path lists the directories and archives to search. For Windows, use a
semicolon (;) to separate items in the path. On other platforms, use a
colon (:) to separate items.

For more information, see "jshell" reference page at https://docs.oracle.com/en/java/javase/17/docs/specs/man/jshell.html.

Table of Contents

 About This Book

 Java Tools Terminology

 Java Tools Included in JDK

 javac - The Java Program Compiler

 java - The Java Program Launcher

 jar - The JAR File Tool

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

 jpackage - Binary Package Builder

 javadoc - The Java Document Generator

 jdeps - The Java Class Dependency Analyzer

 jdeprscan - The Java Deprecated API Scanner

 jdb - The Java Debugger

 jcmd - The JVM Diagnostic Tool

 jconsole - Java Monitoring and Management Console

 jstat - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jhsdb - The Java HotSpot Debugger

 jvisualvm (Java VisualVM) - JVM Visual Tool

 jmc - Java Mission Control

 javap - The Java Class File Disassembler

 keytool - Public Key Certificate Tool

 jarsigner - JAR File Signer

jshell - Java Language Shell

jshell - What Is It

 jshell - Entering Expressions and Statements

 "jshell> /save" - Saving Code Snippet

 "jshell> /edit" - Editing Code Snippet

 jrunscript - Script Code Shell

 Miscellaneous Tools

 native2ascii - Native-to-ASCII Encoding Converter

 JAB (Java Access Bridge) for Windows

 Archived Tutorials

 References

 Full Version in PDF/EPUB