Home > Java > javaTutorial > body text

How to modify JShell's default editor in Java 9?

WBOY
Release: 2023-08-25 23:29:01
forward
1289 people have browsed it

JShell Implementation of REPL (read-evaluate-print loop) that reads code from the command line >, evaluates the given code snippet and print the result back to us.

In JShell, you can use JShell Editor Pad从默认的 JShell 编辑器编辑代码>. We can also use the "/set" command to modify the default editor in order to define another editor. This editor can be used when the "/edit" command is launched. In order to do this, we simply launch the "/set editor [editor]" command.

Suppose we want to set the Notepad application as the default program for editing code, then just type the command: "/set editor notepad.exe".

<strong>jshell> /set editor
|  /set editor -default

jshell> int i = 20
i ==> 20

jshell> double j = 30.0
j ==> 30.0

jshell> /set editor notepad.exe
|  Editor set to: notepad.exe

jshell> /edit</strong>
Copy after login

Now, if we want to use the "/edit" command to modify the code entered in the command prompt, we can open a Notepad application as follows.

如何在Java 9中修改JShell的默认编辑器?

If we can modify the JShell editor by entering <. Because the program does not exist or the path is incorrect, when we execute JShell cannot display the error message when executing the "< 来修改 JShell 编辑器由于程序不存在或者路径不正确,当我们执行“/edit" command. When trying to open the editor we just get an error message as shown below.

<strong>jshell> /set editor emacs
|  Editor set to: emacs

jshell> /set editor
|  /set editor emacs

jshell> /edit
|  Edit Error: process IO failure: Cannot run program "emacs": CreateProcess error=2,
  The system cannot find the file specified</strong>
Copy after login

The above is the detailed content of How to modify JShell's default editor in Java 9?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template