7

I am using the 'jshell command in my machine it is not recognised. But java command is working fine. is there any environment setup for jshell in jdk 10

C:\Users\Kannan
λ jshell
'jshell' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Kannan
λ java -version
java version "10" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
Kannan Thangadurai
  • 1,077
  • 1
  • 17
  • 33

8 Answers8

7

jshell is a part of JDK 10 and it's located in the %JAVA_HOME%\bin folder on Windows.

Possible problems:

  1. You installed JRE 10 only (instead of JDK 10). jshell is NOT part of the JRE.

  2. %JAVA_HOME%\bin is not part of the PATH system variable.

See also: Environment variables for java installation

Alex Shesterov
  • 24,284
  • 11
  • 75
  • 95
4
  1. check if jshell is installed with your Java environment. ls [JAVA-INSTALLEDPATH]/bin
  2. if jshell does not exist download appropriate JDK
  3. if jshell is present append path in your environment profile or use full path.
Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
3

You need to add the bin folder of your Java Development Kit (JDK) installation to the PATH environment variable. The java command works, because the JRE installs a copy of the java.exe executable in C:\ProgramData\Oracle\Java\javapath\ and adds it to the PATH.

For editing the PATH, see How do I set system environment variables in Windows 10? on superuser

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
1

Had the same problem. I set JAVA_HOME and wrapped it with double quotes ("").

JAVA_HOME="C:\Program Files\Java\jdk1.8.0_144"
IKavanagh
  • 5,799
  • 11
  • 40
  • 45
Tonnie
  • 2,439
  • 3
  • 18
  • 24
1

What you have is a JRE. You should install JDK and set JAVA_HOME. Then jshell will start working properly.

Stephen Kennedy
  • 18,869
  • 22
  • 90
  • 106
user3567195
  • 391
  • 1
  • 4
  • 18
1

The same problem has happened to me. Uninstall and Install the right JDK from Oracle website.

steps: 1. Control Panel > System & Security > System > Change Setting > Advance > Change Environment Variable > System Variable > New > Variable Name:"Path" & Variable Value: "C:\Program Files\Java\jdk-10.0.1\bin" (address of the bin)> ok

You are good to go. Here's the link to the video that helped me.

https://www.youtube.com/watch?v=UokTaTwckDw

tkrloltkr
  • 11
  • 2
1

Run you command prompt as Administrator. window -> cmd -> Run as Administrator then type jshell.

subhashis
  • 4,444
  • 7
  • 36
  • 51
1

Remove any default path variable that is set in envirnoment variables when you install JDK apart from JAVA_HOME.Then update your JAVA_HOME to /path of JDK 9 OR Above/

Chinmoy
  • 1,186
  • 11
  • 12