Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is my /etc/paths:


I added a file yuicompressor.jar to /usr/local/bin. Then I ran:

sudo java -jar yuicompressor.jar

but it says

Unable to access jarfile yuicompressor.jar

What am I doing wrong?

share|improve this question
Java does not search the PATH for jars you specify. sh wouldn't work either if is on the PATH. – Daniel Beck Sep 9 '13 at 17:36
Oh wow, now I feel dumb. – Hilbert Sep 9 '13 at 17:48
up vote 2 down vote accepted

PATH is used for executables only. It's what the shell (bash usually on MacOSX) uses for lookups for executables when you don't give an explicit path (such as /usr/bin/java or ./java).

Once you run java, now java is loaded, and it needs to figure out where things are. The shell is done. So, does java itself have any environment vars to check that might help? In general, you may try CLASSPATH. This gives a list of jars, to search for classes that may not be in the normal places java looks for.

But in this case, I don't think it could help, based on your syntax. You're telling it a specific path to a Jarfile. I'd just explicity path the jar out. Probably use a script to do this for you instead of typing this all out. I see something like:


sudo java -jar /path/to/yuicompressor.jar

in your future.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .