Learn JShell with Java 9 - Step by Step
4.4 (14 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
131 students enrolled

Learn JShell with Java 9 - Step by Step

Master JShell - The most important Java 9 new feature
4.4 (14 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
131 students enrolled
Last updated 6/2020
English
English
Current price: $69.99 Original price: $99.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 1.5 hours on-demand video
  • 1 article
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • You will be able to write Java Programs and Snippets using Java REPL JShell
  • You will understand all the important tips and tricks about the Java REPL JShell
  • You will understand and use important Java REPL JShell Commands
  • You will become a more productive Java developer with JShell
  • You will learn to create Java variables, methods and classes with JShell
  • You will learn to explore external Java Libraries with JShell
  • You will learn JShell tips to become a more effective Java Programmer
Course content
Expand 19 lectures 01:34:32
+ JShell for Java Programmers
19 lectures 01:34:32

- Java REPL (Read Evaluate Print Loop) Shell
- Comes by default with JDK 9
- Quickly debug or test or investigate an API or try a new Library
- Quick Learning with immediate feedback. No need to write a PSVM or a Unit test.

Preview 03:48

- Install JDK 9
- Open Command Prompt and type in jshell
- Other option is to cd to the bin folder where JDK 9 is installed and type in jshell
- /exit

Preview 03:20

- int i=10;
- int i=10; int j=10; //multiple statements
- System.out.println(i);
- i = i + j

```
   1 : int x = 10;
   2 : x
   4 : x = x + 10;
   5 : System.out.println(x);
   6 : int i = 10;
   7 :  int j = 20;
   8 : i = i + 10;
   9 :  j = j + 10;
 ```

Preview 04:40

- Tip : Semicolon is not mandatory unless you want to seperate statements on a single line.
- Tip : Comments are supported //
- Quick Tip - Nothing is saved by default!
- Quick Tip - Verbose mode! 
 - jshell -v

Preview 06:02

 - numerical identifier
 - /drop
 - /history

JShell Commands - list, drop and history
05:18

- i = 

    -   i + j
- Multi line comments

JShell Basics - Multiple Lines
03:40

- When expression returns a value
- 10 + 10
- System.out.println($1)
- /set feedback verbose
- silent | normal | concise

JShell Tip - Implicit or Scratch Variables and Feedback options
05:09

```
int cube(int n) {
    return n * n * n; 
}

void printTwice(String str) {
System.out.println(str);
System.out.println(str);
}
```

JShell Basics - Create Java Methods
04:53

- Default imports
- /imports
- importing a new Java class 
  - 2 options - import statement or auto import
  - import java.sql.Timestamp
  - new Timestamp => Shift + Tab i
- Creating a new Java variable using imported class  
  - new Timestamp(); => Shift + Tab v
  - new Timestamp(1000L);=> Shift + Tab v
  - Timestamp temp = new Timestamp(1000L);

JShell Basics - Java Imports
09:10


- methods
- constants
- variables
- Cannot be used in variable initialization

JShell Tip - Forward Referencing
05:54

- Basic Java Class
- Editing a Java class using external editor
- /edit
- /edit Course
- Course course1 = new Course()
- course1.setName("Microservices with Spring Boot");
- Cannot access private variables in a class - course1.name 

JShell Basics - Creating a Java Class
06:50

- Java Class in a package
- Java Class members
- Parameters
- Overloaded methods
- Documentation of a Java Class

JShell Basics - Java API Auto completion
04:47

- All commands start with / - slash or forward slash
   - /help, /?, / followed by tab
- JShell Commands - var, methods and types
- Exceptions

More JShell Tips : Exceptions, var, methods and types Commands and Help
07:43

- /save file.jsh
- /open file.jsh

Saving and Reloading JShell Sessions with Java Instructions
03:01

- Getting a command to be executed at start of JShell
```
/reset
System.out.print("\033[H\033[2J");
/list
/save start.jsh
/set start start.jsh
/reset
/list
/list -all
/set start start.jsh DEFAULT
/reset
/list
/list -all
/history
```

JShell - Setting Custom Start Options
04:32

- /env -class-path commons-lang3-3.6.jar
- import org.apache.commons.lang3.*
- StringUtils.trim("1234 ");

JShell - Playing around with an External Java Library
07:06

 - Shortcuts to commands and options
   - /l
   - /h
   - /l -a
 - Navigation
   - Ctrl + a
   - Ctrl + e
   - Ctrl + k
 - Search Snippets
   - Ctrl + r
   - Ctrl + s
- For the Lazy Guys
```
/set start -retain DEFAULT PRINTING
```

More JShell Tips to become a productive Java Programmer
05:56
Bonus Lecture - 5 Steps to Success
00:38
Requirements
  • You should be an experienced Java Programmer
  • You should have Java 9 installed on your computer
Description

JShell is a new feature in Java 9 which allows you to run code quickly and easily. In this course, you will learn how to use Java REPL JShell to become a more productive programmer. You will learn how to explore Java with JShell and understand the various JShell commands. Added in are tips and tricks to make you a JShell expert.

Here are the step by step details:

  • Introduction to JShell
  • Installing and Launching JShell
  • JShell Basics - Java Variables and Expressions
  • JShell Basics - Few important tips
  • JShell Commands - list, drop and history
  • JShell Basics - Multiple Lines
  • JShell Tip - Implicit or Scratch Variables and Feedback options
  • JShell Basics - Java Methods
  • JShell Basics - Java Imports
  • JShell Tip - Forward Referencing
  • JShell Basics - Java Class
  • JShell Basics - Java Auto completion
  • More JShell Tips : Exceptions, var, methods and types Commands and Help
  • Saving and Reloading JShell Sessions
  • JShell - Setting Custom Start Options
  • JShell - Playing around with an External Library
  • More JShell Tips
Who this course is for:
  • You are a good Java Programmer and want to learn the most important new feature in Java 9 - JShell
  • You want to become more productive at exploring Java APIs and Libraries