简体   繁体   中英

Error - /bin/sh: java: command not found

I get the following error when I try to run JSLint from SublimeText 2 on my Mac:

/bin/sh: java: command not found

I think it is to do with Java not being in the PATH on Mac, can anyone help with this please?

Open up terminal and start editing .bash_profile

vi ~/.bash_profile

then add the following

export JAVA_HOME=/usr/java/jdk<your JDK folder>

export PATH=$PATH:/usr/java/jdk<your JDK folder>/bin

Save and close.

From this article and a couple of others, it looks like you edit your ~/.profile file (the .profile in your home directory), find the line that starts with export PATH=... , and add the Java bin directory at the beginning or end, separating it from the previous/next element with a colon ( : ).

Eg, if it looks like this:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

change it to

export PATH=/opt/local/bin:/opt/local/sbin:$PATH:/path/to/java/bin

or

export PATH=/opt/local/bin:/opt/local/sbin:/path/to/java/bin:$PATH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM