10

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.

Naman
  • 27,789
  • 26
  • 218
  • 353
szab.kel
  • 2,356
  • 5
  • 40
  • 74
  • Could you try starting the jshell in verbose mode using command `jshell -v` ans see if there are any logs pertaining to the failure. – Naman Sep 30 '17 at 19:24
  • @nullpointer Starting with `jshell -v` does not make a difference. – szab.kel Sep 30 '17 at 19:41

1 Answers1

13

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]

skomisa
  • 16,436
  • 7
  • 61
  • 102
  • Did you build winpty or use the releases? I downloaded `winpty-0.4.3-cygwin-2.8.0-x64.tar.gz` but frankly was a bit confused regarding what to do with all the files in it. – Robert Mark Bram Apr 05 '18 at 06:48
  • 3
    _"Did you build winpty or use the releases?"_ => Neither. I was on Win10 and used Git Bash that comes bundled when you install Git, and there was nothing else I needed to do - **winpty** was simply there. But to be clear, if you want to use **jshell** on Windows just open a **cmd** window. The question here specifically relates to using jshell within a Git Bash window on Windows. (Or am I misunderstanding your question?) – skomisa Apr 05 '18 at 15:03
  • @skomisa thanks for the clarification. I have since worked out how to get winpty and use it to launch JShell, which is what I was having issues with (turned out I had the wrong version of winpty, 34 vs 64 bit). :D – Robert Mark Bram Apr 06 '18 at 01:24