From the course: Java 8+ Essential Training: Syntax and Structure

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Test simple Java code in JShell

Test simple Java code in JShell - Java Tutorial

From the course: Java 8+ Essential Training: Syntax and Structure

Start my 1-month free trial

Test simple Java code in JShell

- [Narrator] The JShell command is a mayor new feature of Java 9. When you run JShell you can enter simple Java statements without having to create a whole application or even a Java class. This lets you test simple code before you add it to a larger software package. To run JShell from anywhere in your file system open a Command Prompt or a PowerShell on Windows, or open Terminal on Mac. Make sure you´re added the jdk´s bin directory to your system´s path. On Mac OS this is automatic but on Windows you have to do it yourself. Then, just type jshell. If you have trouble running JShell go back to the previous video on configuring the path and make sure that´s working correctly. When you´re in JShell you can type any Java statement. For example, let´s say I wanted to declare a string value. I´d start with the type of the variable, String. Now, remember, Java is case-sensitive so type it exactly as I´m showing here. Then I´ll give the variable an identifier of s1 and I´ll assign it a…

Contents