JShell

A command line REPL for Java.

JShell gives you a command line for Java.

From the Terminal command line:

$ jshell Practice.java
Jan 08, 2025 4:16:42 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
|  Welcome to JShell -- Version 21.0.5
|  For an introduction type: /help intro

jshell> String[] args = {};
args ==> String[0] {  }

jshell> Practice.main(args);
Yes, this works.

There are some things to notice:

  1. Supply a list (array) of strings in order to run a main method.
  2. Include the class name when trying to call a funtion. main(args) does not work because Java neesds to know what class to look in.
Last modified February 20, 2025: summary -> description (6adf315)