
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
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 Articles
- How to debug JShell in Java 9?
- How to reset the JShell session in Java 9?
- JShell in Java 9?
- How to get JShell documentation in Java 9?
- How to create a Default Cell Editor with textbox in Java?
- How to print the pattern of stars in JShell in Java 9?
- How to save the current JShell session 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 the encapsulation concept in JShell in Java 9?
- How to implement the Fibonacci series in JShell in Java 9?
- Using Variables in JShell of Java 9
- Package Imports in JShell of Java 9
- How to create a thread in JShell in Java 9?
- How to import external libraries in JShell in Java 9?
