views:

246

answers:

1

I'd like to put the yuicompressor jar file in a single folder so that I can call

java -jar yuicompressor-2.4.2.jar ...

from anywhere on my system, with cygwin. For bash files I use I simply put them in a common folder, and added the folder's path to my windows user's PATH environment variable and the bash commands were found in cygwin.

when I echo $PATH I see the folder I put the yuicompressor jar into listed in the $PATH..

But when I try java -jar yuicompressor-x.y.z.jar myfile.js -o myfile-min.js (for example) I get the following error message:

Unable to access jarfile yuicompressor-2.4.2.jar

Even when I try providing an absolute path to the jarfile I get the same error message..

How can I do this?

+1  A: 

The PATH environment variable is a list of directories the shell will search through in an attempt to run a command.

java.exe will not search the directories on the PATH environment variable to try and locate the archive you are attempting to run. So running java -jar yuicompressor-2.4.2.jar from any directory other than the one containing the archive would be expected to fail.

What is the full command you are attempting when providing an absolute path?

Simon Lieschke
"What is the full command you are attempting when providing an absolute path?" java -jar yuicompressor-x.y.z.jar myfile.js -o myfile-min.js
Erik Vold
That's not an absolute path to the archive. (I'm after exactly what you're using in your absolute path call because I would expect to see an absolute path work.)
Simon Lieschke
an absolute path is what I'm trying to avoid, so I don't know what you mean when you ask "What is the full command you are attempting when providing an absolute path?". I'm not attempting to use a absolute path because I don't want to use an absolute path.. You'll have to clarify your meaning.
Erik Vold
I'm was after the full command you entered when using an absolute path, e.g. `java -jar C:\path\to\yuicompressor-2.4.2.jar myfile.js -o myfile-min.js`.I'm assuming you want to avoid the absolute path because you don't want to have to type the full path out when running the command? I have an idea for a solution that wouldn't require entering the full path at your prompt, but would require the absolute path to be entered in a shell script. But this is no good if the command with an absolute path fails as well. Hence I want to work out why the absolute path isn't working.
Simon Lieschke
C:\www\erikvold.com\js>java -jar C:\commands\yucompressor-2.4.2.jar string.js -o test-min.jsUnable to access jarfile C:\commands\yucompressor-2.4.2.jar
Erik Vold
Looks right to me. Maybe you've got a permissions issue? I tried setting the file permissions on the archive so I didn't have access to it and ran the command again, and got the "Unable to access jarfile" message. Try running an independent command on the file, something like `cat C:\commands\yucompressor-2.4.2.jar` and see what happens to confirm/eliminate it being a file permissions issue.
Simon Lieschke