Burt
Burt

Reputation: 7758

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?

Upvotes: 6

Views: 34470

Answers (2)

Teejay
Teejay

Reputation: 7481

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.

Upvotes: 5

T.J. Crowder
T.J. Crowder

Reputation: 1075049

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

Upvotes: 4

Related Questions