jshell - Entering Expressions and Statements

This section provides a tutorial example on how to start 'jshell' and enter expressions and statements.

As the first test, I want to start "jshell" and enter a few Java expressions and Java statements:

C:\herong>jshell
|  Welcome to JShell -- Version 10.0.1
|  For an introduction type: /help intro

jshell> Math.PI*0.5*0.5;
$1 ==> 0.7853981633974483

jshell> System.out.println("Hello World!");
Hello World!

jshell> String x = "Apple", y = "Orange";
x ==> "Apple"
y ==> "Orange"

jshell> int s = 0;
s ==> 0

jshell> for (int i=1; i<=100; i++) {s += i;};

jshell> s;
s ==> 5050

jshell> class Hello {
   ...>    public static void print () {
   ...>       System.out.println("Aloha!");
   ...>    }
   ...> }
|  created class Hello

jshell> Hello.print();
Aloha!

jshell> /exit
|  Goodbye (1)

Cool. "jshell" is easy to use.

Last update: 2018.

Table of Contents

 About This Book

 Java Tools Terminology

 Java Tools Included in JDK

 javac - The Java Program Compiler

 jar - The JAR File Tool

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

 java - The Java Program Launcher

 jdb - The Java Debugger

 jcmd - The JVM Diagnostic Tool

 jconsole - Java Monitoring and Management Console

 jstat - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jvisualvm (Java VisualVM) - JVM Visual Tool

 jmc - Java Mission Control

 javap - The Java Class File Disassembler

 keytool - Public Key Certificate Tool

 jarsigner - JAR File Signer

jshell - Java Language Shell

 jshell - What Is It

jshell - Entering Expressions and Statements

 "jshell> /save" - Saving Code Snippet

 "jshell> /edit" - Editing Code Snippet

 native2ascii - Native-to-ASCII Encoding Converter

 Outdated Tutorials

 References

 Full Version in PDF/EPUB