如何在Java 9中获取JShell文档?

2023年 9月 7日 101.8k 0

如何在Java 9中获取JShell文档?

Java 9 引入了一种新的交互式工具,称为JShell。该工具可用于执行表达式、类、接口、枚举等。

详细的文档可以在 JShell 中找到,其中包含完整信息,以及使用其内部命令和各种选项的信息。可以使用两个命令访问此文档:“/help”和“/?”。 JShell的文档不仅限于其内部控制的信息,还包括Javadoc。

在下面的代码片段中,可以通过使用“ /help”命令。

jshell> /help
| Type a Java language expression, statement, or declaration.
| Or type one of the following commands:
| /list [|-all|-start]
| list the source you have typed
| /edit
| edit a source entry referenced by name or id
| /drop
| delete a source entry referenced by name or id
| /save [-all|-history|-start]
| Save snippet source to a file.
| /open
| open a file as source input
| /vars [|-all|-start]
| list the declared variables and their values
| /methods [|-all|-start]
| list the declared methods and their signatures
| /types [|-all|-start]
| list the declared types
| /imports
| list the imported items
| /exit
| exit jshell
| /env [-class-path ] [-module-path ] [-add-modules ] ...
| view or change the evaluation context
| /reset [-class-path ] [-module-path ] [-add-modules ]...
| reset jshell
| /reload [-restore] [-quiet] [-class-path ] [-module-path ]...
| reset and replay relevant history -- current or previous (-restore)
| /history
| history of what you have typed
| /help [|]
| get information about jshell
| /set editor|start|feedback|mode|prompt|truncation|format ...
| set jshell configuration information
| /? [| ]
| get information about jshell
| /!
| re-run last snippet
| /
| re-run snippet by id
| /-
| re-run n-th previous snippet
| For more information type '/help' followed by the name of a command or a subject.
| For example '/help /list' or '/help intro'.
|
| Subjects:
|
| intro
| an introduction to the jshell tool
| shortcuts
| a description of keystrokes for snippet and command completion,
| information access, and automatic code generation
| context
| the evaluation context options for /env /reload and /reset

登录后复制

JShell 打印不同的现有内部命令,并快速介绍它们的用途,并访问其使用的更详细说明。为此,我们只需输入命令:“/help”,然后输入详细的命令名称(例如“/set”命令)。

jshell> /help /set
|
| /set
|
| Set jshell configuration information, including:
| the external editor to use, the start-up definitions to use, a new feedback mode,
| the command prompt, the feedback mode to use, or the format of output.
|
| /set editor [-wait] ...
| Specify the command to launch for the /edit command.
| The is an operating system dependent string.
|
| /set start
| The contents of the specified become the default start-up snippet s and commands.
|
| /set feedback
| Set the feedback mode describing displayed feedback for entered snippets and commands.
|
| /set mode [] -command|-quiet|-delete
| Create or update a user-defined feedback mode, optionally copying from an existing mode.
|
| /set prompt "" ""
| Set the displayed prompts for a given feedback mode.
|
| /set truncation ...
| Set the maximum length of a displayed value.
|
| /set format "" ...
| Configure a feedback mode by setting the format of a field when the selector matches.
|
| /set
| Show editor, start, and feedback settings as /set commands.
| To show the settings of any of the above, omit the set value.
|
| To get more information about one of these forms, use /help with the form specified.
| For example: /help /set format

登录后复制

我们需要找到第三部分输入的命令,是否修改JShell的返回(/set Feedback),以修改默认编辑器(/set editor),或者修改JShell的启动(/set start)。

jshell> /help /set feedback
| Set the feedback mode describing displayed feedback for entered snippets and
commands:
|
| /set feedback [-retain]
|
| Retain the current feedback mode for future sessions:
|
| /set feedback -retain
|
| Show the feedback mode and list available modes:
|
| /set feedback
|
| Where is the name of a previously defined feedback mode.
| You may use just enough letters to make it unique.
| User-defined modes can be added, see '/help /set mode'
|
| When the -retain option is used, the setting will be used in this and future
| runs of the jshell tool.
|
| The form without or -retain displays the current feedback mode and available modes.

登录后复制

以上就是如何在Java 9中获取JShell文档?的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!

相关文章

JavaScript2024新功能:Object.groupBy、正则表达式v标志
PHP trim 函数对多字节字符的使用和限制
新函数 json_validate() 、randomizer 类扩展…20 个PHP 8.3 新特性全面解析
使用HTMX为WordPress增效:如何在不使用复杂框架的情况下增强平台功能
为React 19做准备:WordPress 6.6用户指南
如何删除WordPress中的所有评论

发布评论