Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 913
Burt Avatar asked Jun 07 '12 09:06

Burt


2 Answers

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 (:).

E.g., 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
like image 59
T.J. Crowder Avatar answered Nov 11 '22 03:11

T.J. Crowder


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.

like image 20
Teejay Avatar answered Nov 11 '22 03:11

Teejay