

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to modify the default editor of JShell in Java 9?
JShell implements REPL (Read-Evaluate-Print Loop) that reads the code from the command-line, evaluates the given snippet, and prints the result back to us.
In JShell, it's possible to edit code from the default JShell editor by using JShell Editor Pad. We can also use the "/set" command to modify the default editor in order to define another one. When launching the "/edit" command, this editor can be used. In order to perform this operation, we can 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".
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
Now, if we want to modify the code entered in the command prompt by using the "/edit" command, it can open a notepad application as below.
If we can modify the JShell editor by entering a non-existent program or an incorrect path, JShell can't display an error message when we execute the "/edit" command. We only get an error message when trying to open the editor as below.
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
- Related Questions & Answers
- JShell in Java 9?
- How to debug JShell in Java 9?
- How to reset the JShell session in Java 9?
- Using Variables in JShell of Java 9
- Package Imports in JShell of Java 9
- How to get JShell documentation in Java 9?
- How to print the pattern of stars in JShell in Java 9?
- How to save the current JShell session in Java 9?
- How can we customize the start of JShell in Java 9?
- How to implement the encapsulation concept in JShell in Java 9?
- How to implement the Fibonacci series in JShell in Java 9?
- How to create JShell instance programmatically in Java 9?
- How to implement java.time.LocalDate using JShell in Java 9?
- How to implement JShell using JavaFX in Java 9?
- How JShell tool works internally in Java 9?