- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 JShell tool works internally in Java 9?
JShell tool has introduced in Java 9 that provides a fast and friendly environment that enables us to quickly explore, discover, and experiment with Java language features and extensive libraries.
When the code entered into the JShell console, it is processed by JLine. It is a Java library that allows us to capture on a console. Once the code has been entered, it is parsed by JShell parser in order to determine its type (method, variable, etc.).
JShell Parser is wrapped in a class with the following rules:
- All imports are placed at the top of this class.
- Variables, methods and class declarations become static members of this class.
- Expressions and declarations are wrapped in a method inside this class.
After this step, the generated source code is analyzed and compiled in Bytecode by the Java compiler, then sent to a process running JVM in order to load and execute the code.
In the below code snippet, we can able to launch the JShell tool by simply typing "jshell" in command-line prompt.
C:\Users\User>jshell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell>
When JShell starts, we have a command prompt waiting for input. There are two types of commands that can be entered: JShell internal commands begin with a “/” and Java code.
In the below code snippet, we can able to print both internal commands like "/list" and Java code like System.out.println().
jshell> System.out.println("Tutorialspoint") Tutorialspoint jshell> /list 1 : System.out.println("Tutorialspoint")
- JShell in Java 9?
- How to debug JShell in Java 9?
- How to get JShell documentation in Java 9?
- Using Variables in JShell of Java 9
- Package Imports in JShell of Java 9
- What is the JLink tool in Java 9?
- How to create JShell instance programmatically in Java 9?
- How to reset the JShell session in Java 9?
- How to implement java.time.LocalDate using JShell in Java 9?
- How to implement JShell using JavaFX in Java 9?
- How to import external libraries in JShell in Java 9?
- How to handle an exception in JShell in Java 9?
- How to create scratch variables in JShell in Java 9?
- How to implement a String in JShell in Java 9?
- How to create a thread in JShell in Java 9?