4.35 out of 5
4.35
11 reviews on Udemy

Learn JShell with Java 9 – Step by Step

Master JShell - The most important Java 9 new feature
Instructor:
in28Minutes Official
94 students enrolled
English
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

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

JShell for Java Programmers

1
Introduction to the Course - JShell for Java Programmers
2
Introduction to JShell

- 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.

3
Installing and Launching JShell

- 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

4
JShell Basics - Variables and Expressions

- 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;
 ```

5
JShell Basics - Few important tips

- 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

6
JShell Commands - list, drop and history

 - numerical identifier
 - /drop
 - /history

7
JShell Basics - Multiple Lines

- i = 

    -   i + j
- Multi line comments

8
JShell Tip - Implicit or Scratch Variables and Feedback options

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

9
JShell Basics - Create Java Methods

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

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

10
JShell Basics - Java Imports

- 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);

11
JShell Tip - Forward Referencing


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

12
JShell Basics - Creating a Java Class

- 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 

13
JShell Basics - Java API Auto completion

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

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

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

15
Saving and Reloading JShell Sessions with Java Instructions

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

16
JShell - Setting Custom Start Options

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

17
JShell - Playing around with an External Java Library

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

18
More JShell Tips to become a productive Java Programmer

 - 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
```

19
Bonus Lecture : Coupons for My Best-Selling Courses -30 Day Money Back Guarantee
You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!
4.4
4.4 out of 5
11 Ratings

Detailed Rating

Stars 5
5
Stars 4
5
Stars 3
0
Stars 2
1
Stars 1
0
f4fbd0d99e79d9885cc2ecfaebe39a36
30-Day Money-Back Guarantee

Includes

2 hours on-demand video
1 article
Full lifetime access
Access on mobile and TV
Certificate of Completion