beginnersbook.com

  • Home
  • All Tutorials
    • Learn Servlet
    • Learn JSP
    • Learn JSTL
    • Learn C
    • Learn C++
    • Learn MongoDB
    • Learn XML
    • Learn Python
    • Learn Perl
    • Learn Kotlin
    • Learn jQuery
  • Core Java
  • OOPs
  • Collections
  • Java I/O
  • JSON
  • DBMS

jshell: Command Not Found on Mac OS X

By Chaitanya Singh | Filed Under: Java 9 Features

If you are trying to access jshell on Mac OS X and getting the following error(jshell: command not found) that means you have to configure the $JAVA_HOME/bin in your bash_profile.
jshell Command Not Found
Note: To start jshell you must have java 9 installed on your system. This feature is added in java9 version.

How to set JAVA_HOME path in Mac OS X

1. Open Terminal. To open press command + space key, type “Terminal” and hit Enter.

2. Type vim ~/.bash_profile and Hit Enter.
Set JAVA_HOME path in Mac OS X Step 1

3. Press “I” for insert and type the following two lines in the bash_profile as shown in the screenshot below:

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$JAVA_HOME/bin:
$ANT_HOME/bin:$ANDROID_HOME/build-tools

Set JAVA_HOME path in Mac OS X Step 2

4. Press Escape, type :wq (colon wq) and hit Enter.

5. Type source ~/.bash_profile and Hit Enter.

6. To verify whether JAVA_HOME set or not, type echo $JAVA_HOME and hit Enter.
echo JAVA_HOME

7. Now you would be able to access jshell. To start jshell, type jshell and hit Enter, you should see a welcome message like this:
Start JShell

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Java 9 Tutorial

  • Java 9 features
  • JShell
  • Immutable List
  • Immutable Set
  • Immutable Map
  • Private Methods in Interface
  • Try-With-Resources Enhancement
  • Java 9 -Diamond operator Enhancement
  • @SafeVarargs annotation
  • Java 9 - Stream API Enhancements
  • Java 9 Modules

Recently Added..

  • JSON Tutorial
  • Java Regular Expressions Tutorial
  • Java Enum Tutorial
  • Java Annotations Tutorial

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap