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:

herong> jshell
|  Welcome to JShell -- Version 12.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();

jshell> /exit
|  Goodbye (1)

Cool. "jshell" is easy to use.

Table of Contents

 About This Book

 Java Tools Terminology

 Java Tools Included in JDK

 javac - The Java Program Compiler

 java - The Java Program Launcher

 jar - The JAR File Tool

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

 jpackage - Binary Package Builder

 javadoc - The Java Document Generator

 jdeps - The Java Class Dependency Analyzer

 jdeprscan - The Java Deprecated API Scanner

 jdb - The Java Debugger

 jcmd - The JVM Diagnostic Tool

 jconsole - Java Monitoring and Management Console

 jstat - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jhsdb - The Java HotSpot Debugger

 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

 jrunscript - Script Code Shell

 Miscellaneous Tools

 native2ascii - Native-to-ASCII Encoding Converter

 JAB (Java Access Bridge) for Windows

 Archived Tutorials


 Full Version in PDF/EPUB