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.
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.
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
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.
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:
Leave a Reply