1433 lines
42 KiB
Groff
1433 lines
42 KiB
Groff
.\"t
|
|
.\" Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
|
|
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
.\"
|
|
.\" This code is free software; you can redistribute it and/or modify it
|
|
.\" under the terms of the GNU General Public License version 2 only, as
|
|
.\" published by the Free Software Foundation.
|
|
.\"
|
|
.\" This code is distributed in the hope that it will be useful, but WITHOUT
|
|
.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
.\" version 2 for more details (a copy is included in the LICENSE file that
|
|
.\" accompanied this code).
|
|
.\"
|
|
.\" You should have received a copy of the GNU General Public License version
|
|
.\" 2 along with this work; if not, write to the Free Software Foundation,
|
|
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
.\"
|
|
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
.\" or visit www.oracle.com if you need additional information or have any
|
|
.\" questions.
|
|
.\"
|
|
.\" Automatically generated by Pandoc 2.3.1
|
|
.\"
|
|
.TH "JSHELL" "1" "2020" "JDK 14" "JDK Commands"
|
|
.hy
|
|
.SH NAME
|
|
.PP
|
|
jshell \- interactively evaluate declarations, statements, and
|
|
expressions of the Java programming language in a read\-eval\-print loop
|
|
(REPL)
|
|
.SH SYNOPSIS
|
|
.PP
|
|
\f[CB]jshell\f[R] [\f[I]options\f[R]] [\f[I]load\-files\f[R]]
|
|
.TP
|
|
.B \f[I]options\f[R]
|
|
Command\-line options, separated by spaces.
|
|
See \f[B]Options for jshell\f[R].
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[I]load\-files\f[R]
|
|
One or more scripts to run when the tool is started.
|
|
Scripts can contain any valid code snippets or JShell commands.
|
|
.RS
|
|
.PP
|
|
The script can be a local file or one of following predefined scripts:
|
|
.TP
|
|
.B \f[CB]DEFAULT\f[R]
|
|
Loads the default entries, which are commonly used as imports.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]JAVASE\f[R]
|
|
Imports all Java SE packages.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]PRINTING\f[R]
|
|
Defines \f[CB]print\f[R], \f[CB]println\f[R], and \f[CB]printf\f[R] as
|
|
\f[CB]jshell\f[R] methods for use within the tool.
|
|
.RS
|
|
.RE
|
|
.PP
|
|
For more than one script, use a space to separate the names.
|
|
Scripts are run in the order in which they\[aq]re entered on the command
|
|
line.
|
|
Command\-line scripts are run after startup scripts.
|
|
To run a script after JShell is started, use the \f[CB]/open\f[R] command.
|
|
.PP
|
|
To accept input from standard input and suppress the interactive I/O,
|
|
enter a hyphen (\-) for \f[I]load\-files\f[R].
|
|
This option enables the use of the \f[CB]jshell\f[R] tool in pipe chains.
|
|
.RE
|
|
.SH DESCRIPTION
|
|
.PP
|
|
JShell provides a way to interactively evaluate declarations,
|
|
statements, and expressions of the Java programming language, making it
|
|
easier to learn the language, explore unfamiliar code and APIs, and
|
|
prototype complex code.
|
|
Java statements, variable definitions, method definitions, class
|
|
definitions, import statements, and expressions are accepted.
|
|
The bits of code entered are called snippets.
|
|
.PP
|
|
As snippets are entered, they\[aq]re evaluated, and feedback is
|
|
provided.
|
|
Feedback varies from the results and explanations of actions to nothing,
|
|
depending on the snippet entered and the feedback mode chosen.
|
|
Errors are described regardless of the feedback mode.
|
|
Start with the verbose mode to get the most feedback while learning the
|
|
tool.
|
|
.PP
|
|
Command\-line options are available for configuring the initial
|
|
environment when JShell is started.
|
|
Within JShell, commands are available for modifying the environment as
|
|
needed.
|
|
.PP
|
|
Existing snippets can be loaded from a file to initialize a JShell
|
|
session, or at any time within a session.
|
|
Snippets can be modified within the session to try out different
|
|
variations and make corrections.
|
|
To keep snippets for later use, save them to a file.
|
|
.SH OPTIONS FOR JSHELL
|
|
.TP
|
|
.B \f[CB]\-\-add\-modules\f[R] \f[I]module\f[R][\f[CB],\f[R]\f[I]module\f[R]...]
|
|
Specifies the root modules to resolve in addition to the initial module.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-C\f[R]\f[I]flag\f[R]
|
|
Provides a flag to pass to the compiler.
|
|
To pass more than one flag, provide an instance of this option for each
|
|
flag or flag argument needed.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-class\-path\f[R] \f[I]path\f[R]
|
|
Specifies the directories and archives that are searched to locate class
|
|
files.
|
|
This option overrides the path in the \f[CB]CLASSPATH\f[R] environment
|
|
variable.
|
|
If the environment variable isn\[aq]t set and this option isn\[aq]t
|
|
used, then the current directory is searched.
|
|
For Oracle Solaris, Linux, and macOS, use a colon (:) to separate items
|
|
in the path.
|
|
For Windows, use a semicolon (;) to separate items.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-feedback\f[R] \f[I]mode\f[R]
|
|
Sets the initial level of feedback provided in response to what\[aq]s
|
|
entered.
|
|
The initial level can be overridden within a session by using the
|
|
\f[CB]/set\ feedback\f[R] \f[I]mode\f[R] command.
|
|
The default is \f[CB]normal\f[R].
|
|
.RS
|
|
.PP
|
|
The following values are valid for \f[I]mode\f[R]:
|
|
.TP
|
|
.B \f[CB]verbose\f[R]
|
|
Provides detailed feedback for entries.
|
|
Additional information about the action performed is displayed after the
|
|
result of the action.
|
|
The next prompt is separated from the feedback by a blank line.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]normal\f[R]
|
|
Provides an average amount of feedback.
|
|
The next prompt is separated from the feedback by a blank line.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]concise\f[R]
|
|
Provides minimal feedback.
|
|
The next prompt immediately follows the code snippet or feedback.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]silent\f[R]
|
|
Provides no feedback.
|
|
The next prompt immediately follows the code snippet.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[I]custom\f[R]
|
|
Provides custom feedback based on how the mode is defined.
|
|
Custom feedback modes are created within JShell by using the
|
|
\f[CB]/set\ mode\f[R] command.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-help\f[R] or \f[CB]\-h\f[R] or \f[CB]\-?\f[R]
|
|
Prints a summary of standard options and exits the tool.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-help\-extra\f[R] or \f[CB]\-X\f[R]
|
|
Prints a summary of nonstandard options and exits the tool.
|
|
Nonstandard options are subject to change without notice.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-J\f[R]\f[I]flag\f[R]
|
|
Provides a flag to pass to the runtime system.
|
|
To pass more than one flag, provide an instance of this option for each
|
|
flag or flag argument needed.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-module\-path\f[R] \f[I]modulepath\f[R]
|
|
Specifies where to find application modules.
|
|
For Oracle Solaris, Linux, and macOS, use a colon (:) to separate items
|
|
in the path.
|
|
For Windows, use a semicolon (;) to separate items.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-no\-startup\f[R]
|
|
Prevents startup scripts from running when JShell starts.
|
|
Use this option to run only the scripts entered on the command line when
|
|
JShell is started, or to start JShell without any preloaded information
|
|
if no scripts are entered.
|
|
This option can\[aq]t be used if the \f[CB]\-\-startup\f[R] option is
|
|
used.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-q\f[R]
|
|
Sets the feedback mode to \f[CB]concise\f[R], which is the same as
|
|
entering \f[CB]\-\-feedback\ concise\f[R].
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-R\f[R]\f[I]flag\f[R]
|
|
Provides a flag to pass to the remote runtime system.
|
|
To pass more than one flag, provide an instance of this option for each
|
|
flag or flag argument to pass.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-s\f[R]
|
|
Sets the feedback mode to \f[CB]silent\f[R], which is the same as entering
|
|
\f[CB]\-\-feedback\ silent\f[R].
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-show\-version\f[R]
|
|
Prints version information and enters the tool.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-startup\f[R] \f[I]file\f[R]
|
|
Overrides the default startup script for this session.
|
|
The script can contain any valid code snippets or commands.
|
|
.RS
|
|
.PP
|
|
The script can be a local file or one of the following predefined
|
|
scripts:
|
|
.TP
|
|
.B \f[CB]DEFAULT\f[R]
|
|
Loads the default entries, which are commonly used as imports.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]JAVASE\f[R]
|
|
Imports all Java SE packages.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]PRINTING\f[R]
|
|
Defines \f[CB]print\f[R], \f[CB]println\f[R], and \f[CB]printf\f[R] as
|
|
\f[CB]jshell\f[R] methods for use within the tool.
|
|
.RS
|
|
.RE
|
|
.PP
|
|
For more than one script, provide a separate instance of this option for
|
|
each script.
|
|
Startup scripts are run when JShell is first started and when the
|
|
session is restarted with the \f[CB]/reset\f[R], \f[CB]/reload\f[R], or
|
|
\f[CB]/env\f[R] command.
|
|
Startup scripts are run in the order in which they\[aq]re entered on the
|
|
command line.
|
|
.PP
|
|
This option can\[aq]t be used if the \f[CB]\-\-no\-startup\f[R] option is
|
|
used.
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-v\f[R]
|
|
Sets the feedback mode to \f[CB]verbose\f[R], which is the same as
|
|
entering \f[CB]\-\-feedback\ verbose\f[R].
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-version\f[R]
|
|
Prints version information and exits the tool.
|
|
.RS
|
|
.RE
|
|
.SH JSHELL COMMANDS
|
|
.PP
|
|
Within the \f[CB]jshell\f[R] tool, commands are used to modify the
|
|
environment and manage code snippets.
|
|
.TP
|
|
.B \f[CB]/drop\f[R] {\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]} [{\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]}...]
|
|
Drops snippets identified by name, ID, or ID range, making them
|
|
inactive.
|
|
For a range of IDs, provide the starting ID and ending ID separated with
|
|
a hyphen.
|
|
To provide a list, separate the items in the list with a space.
|
|
Use the \f[CB]/list\f[R] command to see the IDs of code snippets.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/edit\f[R] [\f[I]option\f[R]]
|
|
Opens an editor.
|
|
If no option is entered, then the editor opens with the active snippets.
|
|
.RS
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B {\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]} [{\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]}...]
|
|
Opens the editor with the snippets identified by name, ID, or ID range.
|
|
For a range of IDs, provide the starting ID and ending ID separated with
|
|
a hyphen.
|
|
To provide a list, separate the items in the list with a space.
|
|
Use the \f[CB]/list\f[R] command to see the IDs of code snippets.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-all\f[R]
|
|
Opens the editor with all snippets, including startup snippets and
|
|
snippets that failed, were overwritten, or were dropped.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-start\f[R]
|
|
Opens the editor with startup snippets that were evaluated when JShell
|
|
was started.
|
|
.RS
|
|
.RE
|
|
.PP
|
|
To exit edit mode, close the editor window, or respond to the prompt
|
|
provided if the \f[CB]\-wait\f[R] option was used when the editor was set.
|
|
.PP
|
|
Use the \f[CB]/set\ editor\f[R] command to specify the editor to use.
|
|
If no editor is set, then the following environment variables are
|
|
checked in order: \f[CB]JSHELLEDITOR\f[R], \f[CB]VISUAL\f[R], and
|
|
\f[CB]EDITOR\f[R].
|
|
If no editor is set in JShell and none of the editor environment
|
|
variables is set, then a simple default editor is used.
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/env\f[R] [\f[I]options\f[R]]
|
|
Displays the environment settings, or updates the environment settings
|
|
and restarts the session.
|
|
If no option is entered, then the current environment settings are
|
|
displayed.
|
|
If one or more options are entered, then the session is restarted as
|
|
follows:
|
|
.RS
|
|
.IP \[bu] 2
|
|
Updates the environment settings with the provided options.
|
|
.IP \[bu] 2
|
|
Resets the execution state.
|
|
.IP \[bu] 2
|
|
Runs the startup scripts.
|
|
.IP \[bu] 2
|
|
Silently replays the history in the order entered.
|
|
The history includes all valid snippets or \f[CB]/drop\f[R] commands
|
|
entered at the \f[CB]jshell\f[R] prompt, in scripts entered on the command
|
|
line, or scripts entered with the \f[CB]/open\f[R] command.
|
|
.PP
|
|
Environment settings entered on the command line or provided with a
|
|
previous \f[CB]/reset\f[R], \f[CB]/env\f[R], or \f[CB]/reload\f[R] command are
|
|
maintained unless an \f[I]option\f[R] is entered that overwrites the
|
|
setting.
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B \f[CB]\-\-add\-modules\f[R] \f[I]module\f[R][\f[CB],\f[R]\f[I]module\f[R]...]
|
|
Specifies the root modules to resolve in addition to the initial module.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-add\-exports\f[R] \f[I]source\-module\f[R]\f[CB]/\f[R]\f[I]package\f[R]\f[CB]=\f[R]\f[I]target\-module\f[R][\f[CB],\f[R]\f[I]target\-module\f[R]]*
|
|
Adds an export of \f[I]package\f[R] from \f[I]source\-module\f[R] to
|
|
\f[I]target\-module\f[R].
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-class\-path\f[R] \f[I]path\f[R]
|
|
Specifies the directories and archives that are searched to locate class
|
|
files.
|
|
This option overrides the path in the \f[CB]CLASSPATH\f[R] environment
|
|
variable.
|
|
If the environment variable isn\[aq]t set and this option isn\[aq]t
|
|
used, then the current directory is searched.
|
|
For Oracle Solaris, Linux, and macOS, use a colon (\f[CB]:\f[R]) to
|
|
separate items in the path.
|
|
For Windows, use a semicolon (\f[CB];\f[R]) to separate items.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-module\-path\f[R] \f[I]modulepath\f[R]
|
|
Specifies where to find application modules.
|
|
For Oracle Solaris, Linux, and macOS, use a colon (\f[CB]:\f[R]) to
|
|
separate items in the path.
|
|
For Windows, use a semicolon (\f[CB];\f[R]) to separate items.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/exit\f[R] [\f[I]integer\-expression\-snippet\f[R]]
|
|
Exits the tool.
|
|
If no snippet is entered, the exit status is zero.
|
|
If a snippet is entered and the result of the snippet is an integer, the
|
|
result is used as the exit status.
|
|
If an error occurs, or the result of the snippet is not an integer, an
|
|
error is displayed and the tool remains active.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/history\f[R]
|
|
Displays what was entered in this session.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/help\f[R] [\f[I]command\f[R]|\f[I]subject\f[R]]
|
|
Displays information about commands and subjects.
|
|
If no options are entered, then a summary of information for all
|
|
commands and a list of available subjects are displayed.
|
|
If a valid command is provided, then expanded information for that
|
|
command is displayed.
|
|
If a valid subject is entered, then information about that subject is
|
|
displayed.
|
|
.RS
|
|
.PP
|
|
The following values for \f[I]subject\f[R] are valid:
|
|
.TP
|
|
.B \f[CB]context\f[R]
|
|
Describes the options that are available for configuring the
|
|
environment.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]intro\f[R]
|
|
Provides an introduction to the tool.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]shortcuts\f[R]
|
|
Describes keystrokes for completing commands and snippets.
|
|
See \f[B]Input Shortcuts\f[R].
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/imports\f[R]
|
|
Displays the current active imports, including those from the startup
|
|
scripts and scripts that were entered on the command line when JShell
|
|
was started.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/list\f[R] [\f[I]option\f[R]]
|
|
Displays a list of snippets and their IDs.
|
|
If no option is entered, then all active snippets are displayed, but
|
|
startup snippets aren\[aq]t.
|
|
.RS
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B {\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]} [{\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]}...]
|
|
Displays the snippets identified by name, ID, or ID range.
|
|
For a range of IDs, provide the starting ID and ending ID separated with
|
|
a hyphen.
|
|
To provide a list, separate the items in the list with a space.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-all\f[R]
|
|
Displays all snippets, including startup snippets and snippets that
|
|
failed, were overwritten, or were dropped.
|
|
IDs that begin with \f[CB]s\f[R] are startup snippets.
|
|
IDs that begin with \f[CB]e\f[R] are snippets that failed.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-start\f[R]
|
|
Displays startup snippets that were evaluated when JShell was started.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/methods\f[R] [\f[I]option\f[R]]
|
|
Displays information about the methods that were entered.
|
|
If no option is entered, then the name, parameter types, and return type
|
|
of all active methods are displayed.
|
|
.RS
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B {\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]} [{\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]}...]
|
|
Displays information for methods identified by name, ID, or ID range.
|
|
For a range of IDs, provide the starting ID and ending ID separated with
|
|
a hyphen.
|
|
To provide a list, separate the items in the list with a space.
|
|
Use the \f[CB]/list\f[R] command to see the IDs of code snippets.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-all\f[R]
|
|
Displays information for all methods, including those added when JShell
|
|
was started, and methods that failed, were overwritten, or were dropped.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-start\f[R]
|
|
Displays information for startup methods that were added when JShell was
|
|
started.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/open\f[R] \f[I]file\f[R]
|
|
Opens the script specified and reads the snippets into the tool.
|
|
The script can be a local file or one of the following predefined
|
|
scripts:
|
|
.RS
|
|
.TP
|
|
.B \f[CB]DEFAULT\f[R]
|
|
Loads the default entries, which are commonly used as imports.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]JAVASE\f[R]
|
|
Imports all Java SE packages.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]PRINTING\f[R]
|
|
Defines \f[CB]print\f[R], \f[CB]println\f[R], and \f[CB]printf\f[R] as
|
|
\f[CB]jshell\f[R] methods for use within the tool.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/reload\f[R] [\f[I]options\f[R]]
|
|
Restarts the session as follows:
|
|
.RS
|
|
.IP \[bu] 2
|
|
Updates the environment settings with the provided options, if any.
|
|
.IP \[bu] 2
|
|
Resets the execution state.
|
|
.IP \[bu] 2
|
|
Runs the startup scripts.
|
|
.IP \[bu] 2
|
|
Replays the history in the order entered.
|
|
The history includes all valid snippets or \f[CB]/drop\f[R] commands
|
|
entered at the \f[CB]jshell\f[R] prompt, in scripts entered on the command
|
|
line, or scripts entered with the \f[CB]/open\f[R] command.
|
|
.PP
|
|
Environment settings entered on the command line or provided with a
|
|
previous \f[CB]/reset\f[R], \f[CB]/env\f[R], or \f[CB]/reload\f[R] command are
|
|
maintained unless an \f[I]option\f[R] is entered that overwrites the
|
|
setting.
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B \f[CB]\-\-add\-modules\f[R] \f[I]module\f[R][\f[CB],\f[R]\f[I]module\f[R]...]
|
|
Specifies the root modules to resolve in addition to the initial module.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-add\-exports\f[R] \f[I]source\-module\f[R]\f[CB]/\f[R]\f[I]package\f[R]\f[CB]=\f[R]\f[I]target\-module\f[R][\f[CB],\f[R]\f[I]target\-module\f[R]]*
|
|
Adds an export of \f[I]package\f[R] from \f[I]source\-module\f[R] to
|
|
\f[I]target\-module\f[R].
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-class\-path\f[R] \f[I]path\f[R]
|
|
Specifies the directories and archives that are searched to locate class
|
|
files.
|
|
This option overrides the path in the \f[CB]CLASSPATH\f[R] environment
|
|
variable.
|
|
If the environment variable isn\[aq]t set and this option isn\[aq]t
|
|
used, then the current directory is searched.
|
|
For Oracle Solaris, Linux, and macOS, use a colon (\f[CB]:\f[R]) to
|
|
separate items in the path.
|
|
For Windows, use a semicolon (\f[CB];\f[R]) to separate items.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-module\-path\f[R] \f[I]modulepath\f[R]
|
|
Specifies where to find application modules.
|
|
For Oracle Solaris, Linux, and macOS, use a colon (\f[CB]:\f[R]) to
|
|
separate items in the path.
|
|
For Windows, use a semicolon (\f[CB];\f[R]) to separate items.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-quiet\f[R]
|
|
Replays the valid history without displaying it.
|
|
Errors are displayed.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-restore\f[R]
|
|
Resets the environment to the state at the start of the previous run of
|
|
the tool or to the last time a \f[CB]/reset\f[R], \f[CB]/reload\f[R], or
|
|
\f[CB]/env\f[R] command was executed in the previous run.
|
|
The valid history since that point is replayed.
|
|
Use this option to restore a previous JShell session.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/reset\f[R] [\f[I]options\f[R]]
|
|
Discards all entered snippets and restarts the session as follows:
|
|
.RS
|
|
.IP \[bu] 2
|
|
Updates the environment settings with the provided options, if any.
|
|
.IP \[bu] 2
|
|
Resets the execution state.
|
|
.IP \[bu] 2
|
|
Runs the startup scripts.
|
|
.PP
|
|
History is not replayed.
|
|
All code that was entered is lost.
|
|
.PP
|
|
Environment settings entered on the command line or provided with a
|
|
previous \f[CB]/reset\f[R], \f[CB]/env\f[R], or \f[CB]/reload\f[R] command are
|
|
maintained unless an \f[I]option\f[R] is entered that overwrites the
|
|
setting.
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B \f[CB]\-\-add\-modules\f[R] \f[I]module\f[R][\f[CB],\f[R]\f[I]module\f[R]...]
|
|
Specifies the root modules to resolve in addition to the initial module.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-add\-exports\f[R] \f[I]source\-module\f[R]\f[CB]/\f[R]\f[I]package\f[R]\f[CB]=\f[R]\f[I]target\-module\f[R][\f[CB],\f[R]\f[I]target\-module\f[R]]*
|
|
Adds an export of \f[I]package\f[R] from \f[I]source\-module\f[R] to
|
|
\f[I]target\-module\f[R].
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-class\-path\f[R] \f[I]path\f[R]
|
|
Specifies the directories and archives that are searched to locate class
|
|
files.
|
|
This option overrides the path in the \f[CB]CLASSPATH\f[R] environment
|
|
variable.
|
|
If the environment variable isn\[aq]t set and this option isn\[aq]t
|
|
used, then the current directory is searched.
|
|
For Oracle Solaris, Linux, and macOS, use a colon (\f[CB]:\f[R]) to
|
|
separate items in the path.
|
|
For Windows, use a semicolon (\f[CB];\f[R]) to separate items.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-\-module\-path\f[R] \f[I]modulepath\f[R]
|
|
Specifies where to find application modules.
|
|
For Oracle Solaris, Linux, and macOS, use a colon (\f[CB]:\f[R]) to
|
|
separate items in the path.
|
|
For Windows, use a semicolon (\f[CB];\f[R]) to separate items.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/save\f[R] [\f[I]options\f[R]] \f[I]file\f[R]
|
|
Saves snippets and commands to the file specified.
|
|
If no options are entered, then active snippets are saved.
|
|
.RS
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B {\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]} [{\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]}...]
|
|
Saves the snippets and commands identified by name, ID, or ID range.
|
|
For a range of IDs, provide the starting ID and ending ID separated with
|
|
a hyphen.
|
|
To provide a list, separate the items in the list with a space.
|
|
Use the \f[CB]/list\f[R] command to see the IDs of the code snippets.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-all\f[R]
|
|
Saves all snippets, including startup snippets and snippets that were
|
|
overwritten or failed.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-history\f[R]
|
|
Saves the sequential history of all commands and snippets entered in the
|
|
current session.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-start\f[R]
|
|
Saves the current startup settings.
|
|
If no startup scripts were provided, then an empty file is saved.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/set\f[R] [\f[I]setting\f[R]]
|
|
Sets configuration information, including the external editor, startup
|
|
settings, and feedback mode.
|
|
This command is also used to create a custom feedback mode with
|
|
customized prompt, format, and truncation values.
|
|
If no setting is entered, then the current setting for the editor,
|
|
startup settings, and feedback mode are displayed.
|
|
.RS
|
|
.PP
|
|
The following values are valid for \f[CB]setting\f[R]:
|
|
.TP
|
|
.B \f[CB]editor\f[R] [\f[I]options\f[R]] [\f[I]command\f[R]]
|
|
Sets the command used to start an external editor when the
|
|
\f[CB]/edit\f[R] command is entered.
|
|
The command can include command arguments separated by spaces.
|
|
If no command or options are entered, then the current setting is
|
|
displayed.
|
|
.RS
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B \f[CB]\-default\f[R]
|
|
Sets the editor to the default editor provided with JShell.
|
|
This option can\[aq]t be used if a command for starting an editor is
|
|
entered.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-delete\f[R]
|
|
Sets the editor to the one in effect when the session started.
|
|
If used with the \f[CB]\-retain\f[R] option, then the retained editor
|
|
setting is deleted and the editor is set to the first of the following
|
|
environment variables found: \f[CB]JSHELLEDITOR\f[R], \f[CB]VISUAL\f[R], or
|
|
\f[CB]EDITOR\f[R].
|
|
If none of the editor environment variables are set, then this option
|
|
sets the editor to the default editor.
|
|
.RS
|
|
.PP
|
|
This option can\[aq]t be used if a command for starting an editor is
|
|
entered.
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-retain\f[R]
|
|
Saves the editor setting across sessions.
|
|
If no other option or a command is entered, then the current setting is
|
|
saved.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-wait\f[R]
|
|
Prompts the user to indicate when editing is complete.
|
|
Otherwise control returns to JShell when the editor exits.
|
|
Use this option if the editor being used exits immediately, for example,
|
|
when an edit window already exists.
|
|
This option is valid only when a command for starting an editor is
|
|
entered.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]feedback\f[R] [\f[I]mode\f[R]]
|
|
Sets the feedback mode used to respond to input.
|
|
If no mode is entered, then the current mode is displayed.
|
|
.RS
|
|
.PP
|
|
The following modes are valid: \f[CB]concise\f[R], \f[CB]normal\f[R],
|
|
\f[CB]silent\f[R], \f[CB]verbose\f[R], and any custom mode created with the
|
|
\f[CB]/set\ mode\f[R] command.
|
|
.RE
|
|
.TP
|
|
.B \f[CB]format\f[R] \f[I]mode\f[R] \f[I]field\f[R] \f[CB]"\f[R]\f[I]format\-string\f[R]\f[CB]"\f[R] \f[I]selector\f[R]
|
|
Sets the format of the feedback provided in response to input.
|
|
If no mode is entered, then the current formats for all fields for all
|
|
feedback modes are displayed.
|
|
If only a mode is entered, then the current formats for that mode are
|
|
displayed.
|
|
If only a mode and field are entered, then the current formats for that
|
|
field are displayed.
|
|
.RS
|
|
.PP
|
|
To define a format, the following arguments are required:
|
|
.TP
|
|
.B \f[I]mode\f[R]
|
|
Specifies a feedback mode to which the response format is applied.
|
|
Only custom modes created with the \f[CB]/set\ mode\f[R] command can be
|
|
modified.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[I]field\f[R]
|
|
Specifies a context\-specific field to which the response format is
|
|
applied.
|
|
The fields are described in the online help, which is accessed from
|
|
JShell using the \f[CB]/help\ /set\ format\f[R] command.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]"\f[R]\f[I]format\-string\f[R]\f[CB]"\f[R]
|
|
Specifies the string to use as the response format for the specified
|
|
field and selector.
|
|
The structure of the format string is described in the online help,
|
|
which is accessed from JShell using the \f[CB]/help\ /set\ format\f[R]
|
|
command.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[I]selector\f[R]
|
|
Specifies the context in which the response format is applied.
|
|
The selectors are described in the online help, which is accessed from
|
|
JShell using the \f[CB]/help\ /set\ format\f[R] command.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]mode\f[R] [\f[I]mode\-name\f[R]] [\f[I]existing\-mode\f[R]] [\f[I]options\f[R]]
|
|
Creates a custom feedback mode with the mode name provided.
|
|
If no mode name is entered, then the settings for all modes are
|
|
displayed, which includes the mode, prompt, format, and truncation
|
|
settings.
|
|
If the name of an existing mode is provided, then the settings from the
|
|
existing mode are copied to the mode being created.
|
|
.RS
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B \f[CB]\-command\f[R]|\f[CB]\-quiet\f[R]
|
|
Specifies the level of feedback displayed for commands when using the
|
|
mode.
|
|
This option is required when creating a feedback mode.
|
|
Use \f[CB]\-command\f[R] to show information and verification feedback for
|
|
commands.
|
|
Use \f[CB]\-quiet\f[R] to show only essential feedback for commands, such
|
|
as error messages.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-delete\f[R]
|
|
Deletes the named feedback mode for this session.
|
|
The name of the mode to delete is required.
|
|
To permanently delete a retained mode, use the \f[CB]\-retain\f[R] option
|
|
with this option.
|
|
Predefined modes can\[aq]t be deleted.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-retain\f[R]
|
|
Saves the named feedback mode across sessions.
|
|
The name of the mode to retain is required.
|
|
.RS
|
|
.RE
|
|
.PP
|
|
Configure the new feedback mode using the \f[CB]/set\ prompt\f[R],
|
|
\f[CB]/set\ format\f[R], and \f[CB]/set\ truncation\f[R] commands.
|
|
.PP
|
|
To start using the new mode, use the \f[CB]/set\ feedback\f[R] command.
|
|
.RE
|
|
.TP
|
|
.B \f[CB]prompt\f[R] \f[I]mode\f[R] \f[CB]"\f[R]\f[I]prompt\-string\f[R]\f[CB]"\f[R] \f[CB]"\f[R]\f[I]continuation\-prompt\-string\f[R]\f[CB]"\f[R]
|
|
Sets the prompts for input within JShell.
|
|
If no mode is entered, then the current prompts for all feedback modes
|
|
are displayed.
|
|
If only a mode is entered, then the current prompts for that mode are
|
|
displayed.
|
|
.RS
|
|
.PP
|
|
To define a prompt, the following arguments are required:
|
|
.TP
|
|
.B \f[I]mode\f[R]
|
|
Specifies the feedback mode to which the prompts are applied.
|
|
Only custom modes created with the \f[CB]/set\ mode\f[R] command can be
|
|
modified.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]"\f[R]\f[I]prompt\-string\f[R]\f[CB]"\f[R]
|
|
Specifies the string to use as the prompt for the first line of input.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]"\f[R]\f[I]continuation\-prompt\-string\f[R]\f[CB]"\f[R]
|
|
Specifies the string to use as the prompt for the additional input lines
|
|
needed to complete a snippet.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]start\f[R] [\f[CB]\-retain\f[R]] [\f[I]file\f[R] [\f[I]file\f[R]...]|\f[I]option\f[R]]
|
|
Sets the names of the startup scripts used when the next
|
|
\f[CB]/reset\f[R], \f[CB]/reload\f[R], or \f[CB]/env\f[R] command is entered.
|
|
If more than one script is entered, then the scripts are run in the
|
|
order entered.
|
|
If no scripts or options are entered, then the current startup settings
|
|
are displayed.
|
|
.RS
|
|
.PP
|
|
The scripts can be local files or one of the following predefined
|
|
scripts:
|
|
.TP
|
|
.B \f[CB]DEFAULT\f[R]
|
|
Loads the default entries, which are commonly used as imports.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]JAVASE\f[R]
|
|
Imports all Java SE packages.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]PRINTING\f[R]
|
|
Defines \f[CB]print\f[R], \f[CB]println\f[R], and \f[CB]printf\f[R] as
|
|
\f[CB]jshell\f[R] methods for use within the tool.
|
|
.RS
|
|
.RE
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B \f[CB]\-default\f[R]
|
|
Sets the startup settings to the default settings.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-none\f[R]
|
|
Specifies that no startup settings are used.
|
|
.RS
|
|
.RE
|
|
.PP
|
|
Use the \f[CB]\-retain\f[R] option to save the start setting across
|
|
sessions.
|
|
.RE
|
|
.TP
|
|
.B \f[CB]truncation\f[R] \f[I]mode\f[R] \f[I]length\f[R] \f[I]selector\f[R]
|
|
Sets the maximum length of a displayed value.
|
|
If no mode is entered, then the current truncation values for all
|
|
feedback modes are displayed.
|
|
If only a mode is entered, then the current truncation values for that
|
|
mode are displayed.
|
|
.RS
|
|
.PP
|
|
To define truncation values, the following arguments are required:
|
|
.TP
|
|
.B \f[I]mode\f[R]
|
|
Specifies the feedback mode to which the truncation value is applied.
|
|
Only custom modes created with the \f[CB]/set\ mode\f[R] command can be
|
|
modified.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[I]length\f[R]
|
|
Specifies the unsigned integer to use as the maximum length for the
|
|
specified selector.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[I]selector\f[R]
|
|
Specifies the context in which the truncation value is applied.
|
|
The selectors are described in the online help, which is accessed from
|
|
JShell using the \f[CB]/help\ /set\ truncation\f[R] command.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/types\f[R] [\f[I]option\f[R]]
|
|
Displays classes, interfaces, and enums that were entered.
|
|
If no option is entered, then all current active classes, interfaces,
|
|
and enums are displayed.
|
|
.RS
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B {\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]} [{\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]}...]
|
|
Displays information for classes, interfaces, and enums identified by
|
|
name, ID, or ID range.
|
|
For a range of IDs, provide the starting ID and ending ID separated with
|
|
a hyphen.
|
|
To provide a list, separate the items in the list with a space.
|
|
Use the \f[CB]/list\f[R] command to see the IDs of the code snippets.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-all\f[R]
|
|
Displays information for all classes, interfaces, and enums, including
|
|
those added when JShell was started, and classes, interfaces, and enums
|
|
that failed, were overwritten, or were dropped.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-start\f[R]
|
|
Displays information for startup classes, interfaces, and enums that
|
|
were added when JShell was started.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/vars\f[R] [\f[I]option\f[R]]
|
|
Displays the name, type, and value of variables that were entered.
|
|
If no option is entered, then all current active variables are
|
|
displayed.
|
|
.RS
|
|
.PP
|
|
The following options are valid:
|
|
.TP
|
|
.B {\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]} [{\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]}...]
|
|
Displays information for variables identified by name, ID, or ID range.
|
|
For a range of IDs, provide the starting ID and ending ID separated with
|
|
a hyphen.
|
|
To provide a list, separate the items in the list with a space.
|
|
Use the \f[CB]/list\f[R] command to see the IDs of the code snippets.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-all\f[R]
|
|
Displays information for all variables, including those added when
|
|
JShell was started, and variables that failed, were overwritten, or were
|
|
dropped.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]\-start\f[R]
|
|
Displays information for startup variables that were added when JShell
|
|
was started.
|
|
.RS
|
|
.RE
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/?\f[R]
|
|
Same as the \f[CB]/help\f[R] command.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/!\f[R]
|
|
Reruns the last snippet.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/\f[R]{\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]} [{\f[I]name\f[R]|\f[I]id\f[R]|\f[I]startID\f[R]\f[CB]\-\f[R]\f[I]endID\f[R]}...]
|
|
Reruns the snippets identified by ID, range of IDs, or name.
|
|
For a range of IDs, provide the starting ID and ending ID separated with
|
|
a hyphen.
|
|
To provide a list, separate the items in the list with a space.
|
|
The first item in the list must be an ID or ID range.
|
|
Use the \f[CB]/list\f[R] command to see the IDs of the code snippets.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[CB]/\-\f[R]\f[I]n\f[R]
|
|
Reruns the \-\f[I]n\f[R]th previous snippet.
|
|
For example, if 15 code snippets were entered, then \f[CB]/\-4\f[R] runs
|
|
the 11th snippet.
|
|
Commands aren\[aq]t included in the count.
|
|
.RS
|
|
.RE
|
|
.SH INPUT SHORTCUTS
|
|
.PP
|
|
The following shortcuts are available for entering commands and snippets
|
|
in JShell.
|
|
.SS Tab completion
|
|
.TP
|
|
.B \f[B]<tab>\f[R]
|
|
When entering snippets, commands, subcommands, command arguments, or
|
|
command options, use the Tab key to automatically complete the item.
|
|
If the item can\[aq]t be determined from what was entered, then possible
|
|
options are provided.
|
|
.RS
|
|
.PP
|
|
When entering a method call, use the Tab key after the method call\[aq]s
|
|
opening parenthesis to see the parameters for the method.
|
|
If the method has more than one signature, then all signatures are
|
|
displayed.
|
|
Pressing the Tab key a second time displays the description of the
|
|
method and the parameters for the first signature.
|
|
Continue pressing the Tab key for a description of any additional
|
|
signatures.
|
|
.RE
|
|
.TP
|
|
.B \f[B]Shift+<Tab> V\f[R]
|
|
After entering a complete expression, use this key sequence to convert
|
|
the expression to a variable declaration of a type determined by the
|
|
type of the expression.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[B]Shift+<Tab> M\f[R]
|
|
After entering a complete expression or statement, use this key sequence
|
|
to convert the expression or statement to a method declaration.
|
|
If an expression is entered, the return type is based on the type of the
|
|
expression.
|
|
.RS
|
|
.RE
|
|
.TP
|
|
.B \f[B]Shift+<Tab> I\f[R]
|
|
When an identifier is entered that can\[aq]t be resolved, use this key
|
|
sequence to show possible imports that resolve the identifier based on
|
|
the content of the specified class path.
|
|
.RS
|
|
.RE
|
|
.SS Command abbreviations
|
|
.PP
|
|
An abbreviation of a command is accepted if the abbreviation uniquely
|
|
identifies a command.
|
|
For example, \f[CB]/l\f[R] is recognized as the \f[CB]/list\f[R] command.
|
|
However, \f[CB]/s\f[R] isn\[aq]t a valid abbreviation because it can\[aq]t
|
|
be determined if the \f[CB]/set\f[R] or \f[CB]/save\f[R] command is meant.
|
|
Use \f[CB]/se\f[R] for the \f[CB]/set\f[R] command or \f[CB]/sa\f[R] for the
|
|
\f[CB]/save\f[R] command.
|
|
.PP
|
|
Abbreviations are also accepted for subcommands, command arguments, and
|
|
command options.
|
|
For example, use \f[CB]/m\ \-a\f[R] to display all methods.
|
|
.SS History navigation
|
|
.PP
|
|
A history of what was entered is maintained across sessions.
|
|
Use the up and down arrows to scroll through commands and snippets from
|
|
the current and past sessions.
|
|
Use the Ctrl key with the up and down arrows to skip all but the first
|
|
line of multiline snippets.
|
|
.SS History search
|
|
.PP
|
|
Use the Ctrl+R key combination to search the history for the string
|
|
entered.
|
|
The prompt changes to show the string and the match.
|
|
Ctrl+R searches backwards from the current location in the history
|
|
through earlier entries.
|
|
Ctrl+S searches forward from the current location in the history though
|
|
later entries.
|
|
.SH INPUT EDITING
|
|
.PP
|
|
The editing capabilities of JShell are similar to that of other common
|
|
shells.
|
|
Keyboard keys and key combinations provide line editing shortcuts.
|
|
The Ctrl key and Meta key are used in key combinations.
|
|
If your keyboard doesn\[aq]t have a Meta key, then the Alt key is often
|
|
mapped to provide Meta key functionality.
|
|
.PP
|
|
.TS
|
|
tab(@);
|
|
l l.
|
|
T{
|
|
Key or Key Combination
|
|
T}@T{
|
|
Action
|
|
T}
|
|
_
|
|
T{
|
|
Return
|
|
T}@T{
|
|
Enter the current line.
|
|
T}
|
|
T{
|
|
Left arrow
|
|
T}@T{
|
|
Move the cursor to the left one character.
|
|
T}
|
|
T{
|
|
Right arrow
|
|
T}@T{
|
|
Move the cursor to the right one character.
|
|
T}
|
|
T{
|
|
Ctrl+A
|
|
T}@T{
|
|
Move the cursor to the beginning of the line.
|
|
T}
|
|
T{
|
|
Ctrl+E
|
|
T}@T{
|
|
Move the cursor to the end of the line.
|
|
T}
|
|
T{
|
|
Meta+B
|
|
T}@T{
|
|
Move the cursor to the left one word.
|
|
T}
|
|
T{
|
|
Meta+F
|
|
T}@T{
|
|
Move the cursor to the right one word.
|
|
T}
|
|
T{
|
|
Delete
|
|
T}@T{
|
|
Delete the character under the cursor.
|
|
T}
|
|
T{
|
|
Backspace
|
|
T}@T{
|
|
Delete the character before the cursor.
|
|
T}
|
|
T{
|
|
Ctrl+K
|
|
T}@T{
|
|
Delete the text from the cursor to the end of the line.
|
|
T}
|
|
T{
|
|
Meta+D
|
|
T}@T{
|
|
Delete the text from the cursor to the end of the word.
|
|
T}
|
|
T{
|
|
Ctrl+W
|
|
T}@T{
|
|
Delete the text from the cursor to the previous white space.
|
|
T}
|
|
T{
|
|
Ctrl+Y
|
|
T}@T{
|
|
Paste the most recently deleted text into the line.
|
|
T}
|
|
T{
|
|
Meta+Y
|
|
T}@T{
|
|
After Ctrl+Y, press to cycle through the previously deleted text.
|
|
T}
|
|
.TE
|
|
.SH EXAMPLE OF STARTING AND STOPPING A JSHELL SESSION
|
|
.PP
|
|
JShell is provided with the JDK.
|
|
To start a session, enter \f[CB]jshell\f[R] on the command line.
|
|
A welcome message is printed, and a prompt for entering commands and
|
|
snippets is provided.
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
%\ jshell
|
|
|\ \ Welcome\ to\ JShell\ \-\-\ Version\ 9
|
|
|\ \ For\ an\ introduction\ type:\ /help\ intro
|
|
|
|
jshell>
|
|
\f[R]
|
|
.fi
|
|
.PP
|
|
To see which snippets were automatically loaded when JShell started, use
|
|
the \f[CB]/list\ \-start\f[R] command.
|
|
The default startup snippets are import statements for common packages.
|
|
The ID for each snippet begins with the letter \f[I]s\f[R], which
|
|
indicates it\[aq]s a startup snippet.
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
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>
|
|
\f[R]
|
|
.fi
|
|
.PP
|
|
To end the session, use the \f[CB]/exit\f[R] command.
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
jshell>\ /exit
|
|
|\ \ Goodbye
|
|
|
|
%
|
|
\f[R]
|
|
.fi
|
|
.SH EXAMPLE OF ENTERING SNIPPETS
|
|
.PP
|
|
Snippets are Java statements, variable definitions, method definitions,
|
|
class definitions, import statements, and expressions.
|
|
Terminating semicolons are automatically added to the end of a completed
|
|
snippet if they\[aq]re missing.
|
|
.PP
|
|
The following example shows two variables and a method being defined,
|
|
and the method being run.
|
|
Note that a scratch variable is automatically created to hold the result
|
|
because no variable was provided.
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
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
|
|
\f[R]
|
|
.fi
|
|
.SH EXAMPLE OF CHANGING SNIPPETS
|
|
.PP
|
|
Change the definition of a variable, method, or class by entering it
|
|
again.
|
|
.PP
|
|
The following examples shows a method being defined and the method run:
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
jshell>\ String\ grade(int\ testScore)\ {
|
|
\ \ \ ...>\ \ \ \ \ if\ (testScore\ >=\ 90)\ {
|
|
\ \ \ ...>\ \ \ \ \ \ \ \ \ return\ "Pass";
|
|
\ \ \ ...>\ \ \ \ \ }
|
|
\ \ \ ...>\ \ \ \ \ return\ "Fail";
|
|
\ \ \ ...>\ }
|
|
|\ \ created\ method\ grade(int)
|
|
|
|
jshell>\ grade(88)
|
|
$3\ ==>\ "Fail"
|
|
\f[R]
|
|
.fi
|
|
.PP
|
|
To change the method \f[CB]grade\f[R] to allow more students to pass,
|
|
enter the method definition again and change the pass score to
|
|
\f[CB]80\f[R].
|
|
Use the up arrow key to retrieve the previous entries to avoid having to
|
|
reenter them and make the change in the \f[CB]if\f[R] statement.
|
|
The following example shows the new definition and reruns the method to
|
|
show the new result:
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
jshell>\ String\ grade(int\ testScore)\ {
|
|
\ \ \ ...>\ \ \ \ \ if\ (testScore\ >=\ 80)\ {
|
|
\ \ \ ...>\ \ \ \ \ \ \ \ \ return\ "Pass";
|
|
\ \ \ ...>\ \ \ \ \ }
|
|
\ \ \ ...>\ \ \ \ \ return\ "Fail";
|
|
\ \ \ ...>\ }
|
|
|\ \ modified\ method\ grade(int)
|
|
|
|
jshell>\ grade(88)
|
|
$5\ ==>\ "Pass"
|
|
\f[R]
|
|
.fi
|
|
.PP
|
|
For snippets that are more than a few lines long, or to make more than a
|
|
few changes, use the \f[CB]/edit\f[R] command to open the snippet in an
|
|
editor.
|
|
After the changes are complete, close the edit window to return control
|
|
to the JShell session.
|
|
The following example shows the command and the feedback provided when
|
|
the edit window is closed.
|
|
The \f[CB]/list\f[R] command is used to show that the pass score was
|
|
changed to \f[CB]85\f[R].
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
jshell>\ /edit\ grade
|
|
|\ \ modified\ method\ grade(int)
|
|
jshell>\ /list\ grade
|
|
|
|
\ \ \ 6\ :\ String\ grade(int\ testScore)\ {
|
|
\ \ \ \ \ \ \ \ \ \ \ if\ (testScore\ >=\ 85)\ {
|
|
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ return\ "Pass";
|
|
\ \ \ \ \ \ \ \ \ \ \ }
|
|
\ \ \ \ \ \ \ \ \ \ \ return\ "Fail";
|
|
\ \ \ \ \ \ \ }
|
|
\f[R]
|
|
.fi
|
|
.SH EXAMPLE OF CREATING A CUSTOM FEEDBACK MODE
|
|
.PP
|
|
The feedback mode determines the prompt that\[aq]s displayed, the
|
|
feedback messages that are provided as snippets are entered, and the
|
|
maximum length of a displayed value.
|
|
Predefined feedback modes are provided.
|
|
Commands for creating custom feedback modes are also provided.
|
|
.PP
|
|
Use the \f[CB]/set\ mode\f[R] command to create a new feedback mode.
|
|
In the following example, the new mode \f[CB]mymode\f[R], is based on the
|
|
predefined feedback mode, \f[CB]normal\f[R], and verifying command
|
|
feedback is displayed:
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
jshell>\ /set\ mode\ mymode\ normal\ \-command
|
|
|\ \ Created\ new\ feedback\ mode:\ mymode
|
|
\f[R]
|
|
.fi
|
|
.PP
|
|
Because the new mode is based on the \f[CB]normal\f[R] mode, the prompts
|
|
are the same.
|
|
The following example shows how to see what prompts are used and then
|
|
changes the prompts to custom strings.
|
|
The first string represents the standard JShell prompt.
|
|
The second string represents the prompt for additional lines in
|
|
multiline snippets.
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
jshell>\ /set\ prompt\ mymode
|
|
|\ \ /set\ prompt\ mymode\ "\\njshell>\ "\ "\ \ \ ...>\ "
|
|
|
|
jshell>\ /set\ prompt\ mymode\ "\\nprompt$\ "\ "\ \ \ continue$\ "
|
|
\f[R]
|
|
.fi
|
|
.PP
|
|
The maximum length of a displayed value is controlled by the truncation
|
|
setting.
|
|
Different types of values can have different lengths.
|
|
The following example sets an overall truncation value of 72, and a
|
|
truncation value of 500 for variable value expressions:
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
jshell>\ /set\ truncation\ mymode\ 72
|
|
|
|
jshell>\ /set\ truncation\ mymode\ 500\ varvalue
|
|
\f[R]
|
|
.fi
|
|
.PP
|
|
The feedback displayed after snippets are entered is controlled by the
|
|
format setting and is based on the type of snippet entered and the
|
|
action taken for that snippet.
|
|
In the predefined mode \f[CB]normal\f[R], the string \f[CB]created\f[R] is
|
|
displayed when a method is created.
|
|
The following example shows how to change that string to
|
|
\f[CB]defined\f[R]:
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
jshell>\ /set\ format\ mymode\ action\ "defined"\ added\-primary
|
|
\f[R]
|
|
.fi
|
|
.PP
|
|
Use the \f[CB]/set\ feedback\f[R] command to start using the feedback mode
|
|
that was just created.
|
|
The following example shows the custom mode in use:
|
|
.IP
|
|
.nf
|
|
\f[CB]
|
|
jshell>\ /set\ feedback\ mymode
|
|
|\ \ Feedback\ mode:\ mymode
|
|
|
|
prompt$\ int\ square\ (int\ num1){
|
|
\ \ \ continue$\ return\ num1*num1;
|
|
\ \ \ continue$\ }
|
|
|\ \ defined\ method\ square(int)
|
|
|
|
prompt$
|
|
\f[R]
|
|
.fi
|