BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

jshell: Command Not Found on Mac OS X

Last Updated: September 11, 2022 by Chaitanya Singh | Filed Under: java

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

Top Related Articles:

  1. Java 9 Features with Examples
  2. Java Virtual Machine (JVM)
  3. Java 9 JShell (Java Shell) – REPL
  4. java 9 JShell – Working with variables
  5. Java 9 – @SafeVarargs Annotation (with examples)

Tags: Java-9

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

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

Java Tutorial

Java Introduction

  • Java Index
  • Java Introduction
  • History of Java
  • Features of Java
  • C++ vs Java
  • JDK vs JRE vs JVM
  • JVM - Java Virtual Machine
  • First Java Program
  • Variables
  • Data Types
  • Operators

Java Flow Control

  • Java If-else
  • Java Switch-Case
  • Java For loop
  • Java while loop
  • Java do-while loop
  • Continue statement
  • break statement

Java Arrays

  • Java Arrays

OOPs Concepts

  • OOPs Concepts
  • Constructor
  • Java String
  • Static keyword
  • Inheritance
  • Types of inheritance
  • Aggregation
  • Association
  • Super Keyword
  • Method overloading
  • Method overriding
  • Overloading vs Overriding
  • Polymorphism
  • Types of polymorphism
  • Static and dynamic binding
  • Abstract class and methods
  • Interface
  • Abstract class vs interface
  • Encapsulation
  • Packages
  • Access modifiers
  • Garbage Collection
  • Inner classes
  • Static import
  • Static constructor

Java Exception Handling

  • Exception handling
  • Java try-catch
  • Java throw
  • Java throws
  • Checked and Unchecked Exceptions
  • Jav try catch finally
  • Exception Examples
  • Exception Propagation

Collections Framework

  • Collections in Java
  • Java ArrayList
  • Java LinkedList
  • Java Vector
  • Java HashSet
  • Java LinkedHashSet
  • Java TreeSet
  • Java HashMap
  • Java TreeMap
  • Java LinkedHashMap
  • Java Queue
  • Java PriorityQueue
  • Java Deque
  • Comparable interface
  • Comparator interface
  • Collections Interview Questions

MORE ...

  • Java Scanner Class
  • Java 8 Features
  • Java 9 Features
  • Java Conversion
  • Java Date
  • Java Multithreading
  • Java I/O
  • Java Serialization
  • Java Regex
  • Java AWT
  • Java Swing
  • Java Enum
  • Java Annotations
  • Java main method
  • Java Interview Q

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap