JShell language Cheatsheet Cheatsheet

Jshell is Java’s first official REPL (READ-EVAL-PRINT-LOOP) tool which provides interactive use of Java Programming Language elements.


When you evaluate any valid java expression, the result will be stored in the system defined variables.

User-defined variables syntax:

datatype variable name = value;


  • To launch Jshell tool
  • To exit Jshell
  • To list all the declared variables.

    /vars <variableName>
    /vars <variableSnippetId>
    /vars -start
    /vars -all


    jshell> /vars
    |       String name = "OneCompiler"
    |       int id = 1
  • To list all the declared Methods

    /methods <methodName>
    /methods <methodSnippetId>
    /methods -start
    /methods -all


    jshell> /methods
    |    double sum(int,int)
  • To displays classes, interfaces, and enums

    /types <typeName>
    /types <typeSnippetId>
    /types -start
    /types -all
  • To see a list all the snippets
    /list -all
    /list -start
    /list <snippetName>
    /list <snippetId>
  • To save your snippets
  • To personalize your startup entries
    /set start
  • To get help about the list of the JShell commands.
  • To edit code of a method
    /edit method-name
  • To load Code from External Java File into REPL:

    /open filename.java

    You can also provide directory information along wwith filename.java if the file is present in different directory like /open c:\\Documents\\filename.java

  • To Drop a Snippet

    /drop <snippetName>
    /drop <snippetId>

©Copyright 2020 OneCompiler | Privacy Policy | Terms & Conditions