Jshell crashes when i press BackSpace button in windows cmd

This is an issue with the active code page. Specifically 65001 is a problem and popular one to have so my best guess is that this is the one being used but see the link later for some choices.

On windows:

> java --version
java 11.0.1 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

Check the active code page with chcp. If it is set to 65001 (maybe you've been playing around with this hack to get utf-8 characters to display in your terminal) the issue is reliably reproducible.

> chcp 65001
Active code page: 65001
> jshell
|  Welcome to JShell -- Version 11.0.1
|  For an introduction type: /help intro

jshell>TypeAnything<backspace>Exception in thread "main" java.lang.NullPointerException: charsetName
        at java.base/java.lang.String.<init>(String.java:464)
        at ...

The solution

Take your pick from https://docs.oracle.com/javase/6/docs/technotes/guides/intl/encoding.doc.html, but chcp 850 should do the trick.

> chcp 850 && jshell
Active code page: 850
|  Welcome to JShell -- Version 11.0.1
|  For an introduction type: /help intro

jshell> TypeAnything<backspace>

PowerShell specific

The idea is the same (change the console encoding) but the commands are slightly different. Again the idea is to change the encoding. Look at the current code page with [Console]::OutputEncoding.CodePage, we want to switch that to one from the list like 850.

> [Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding(850)
> jshell