Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JShell won't execute anything using Git Bash

I installed Java9 (currently available version on Oracle's site) for Windows (Windows 10 x64 Professional, up to date as well, runs as a vmware virtual machine->VMware Workstation 12). I added the jdk\bin to the User's Path and tried to use Git Bash to execute commands, but even though JShell launches, it won't execute any command after pressing Enter, it just sits there without doing anything.

Interesting thing is it works perfectly with Windows's default command line CMDor Powershell. If I recall correctly Git Bash is Cygwin based. What can be the cause of this?

Also, It is not connected directly to JShell, but I had similar problems on a different machine with some command line tools, like JHipster (works on CMD but not on GitBash).

Obligatory screenshot:-

enter image description here

Edit.: Using jshell -v does not make a difference. Also, using any of the REPL helper commands, like /help or /help intro makes the shell to stop too.

like image 975
szab.kel Avatar asked Sep 30 '17 10:09

szab.kel


1 Answers

I had the same problem. The solution is simple:

"If you are using git bash as your shell on Windows, add winpty before calling jshell ...".

This is the source: https://kichwacoders.com/2017/05/25/woohoo-java-9-has-a-repl-getting-started-with-jshell-and-eclipse-january/

Here's jshell failing in Git Bash:

jshell failing

And here's jshell working in Git Bash when using winpty:

jshell working with winpty

And maybe this approach will also fix your JHipster problem?

[Updated to show clearer screen shots]

like image 95
skomisa Avatar answered Oct 03 '22 22:10

skomisa