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>
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.
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>
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!