简体   繁体   English

无法使用路径环境(Windows XP)全局执行YUIcompressor!

[英]Can't execute YUIcompressor globally using Path environments (Windows XP)!

I typed D:\\yuicompressor-2.42\\build in Path and save it (Windows XP). 我在Path中键入D:\\yuicompressor-2.42\\build并将其保存(Windows XP)。 But when I tried executing it the command line displayed: unable to access jarfile. 但是,当我尝试执行它时,命令行显示:无法访问jarfile。 The same message that appear when I type an incorrect directory. 键入错误的目录时出现的相同消息。

I tried executing the file in this way: 我尝试以这种方式执行文件:

D:\wamp\www\projects\alexchen\alexchen 0.1\scripts>java -jar yuicompressor-2.4.2.jar custom.js -o custom.min.js

according to this 根据这个

I tried calling the file directly and it works: 我尝试直接调用该文件,它可以正常工作:

D:\wamp\www\projects\alexchen\alexchen 0.1\scripts>java -jar D:\yuicompressor-2.4.2\build\yuicompressor-2.4.2.jar custom.js -o custom.min.js

Probably you've misread the docs: 您可能误读了文档:

It's simple to use, as shown in the following example. 用法很简单,如下面的示例所示。 Replace /path/to with the actual path to the YUI Compressor, yuicompressor-2.4.2.jar with the actual version you are using, common.js with your input filename and common.min.js with the name you want the output file to be: 将/ path / to替换为YUI Compressor的实际路径,将yuicompressor-2.4.2.jar替换为您使用的实际版本,将common.js替换为输入文件名,将common.min.js替换为想要输出文件的名称。成为:

java -jar /path/to/yuicompressor-2.4.2.jar common.js -o common.min.js java -jar /path/to/yuicompressor-2.4.2.jar common.js -o common.min.js

This means that you should specify full path to your jar file, not to put it in the Path env variable. 这意味着您应该指定jar文件的完整路径,而不是将其放在Path env变量中。

Of course you can create an enviroment variable that contains the absolute path to your yuicompressor-xyzjar and even include the filename! 当然,您可以创建一个环境变量,其中包含yuicompressor-xyzjar的绝对路径,甚至包括文件名! This then could act as a placeholder or text-expander-like-makro. 这样就可以充当占位符或像文本扩展器一样的makro。

So if, for example, your variable was named "yuicompressor" you could call this one instead of always having to enter the full path over and over again. 因此,例如,如果您的变量名为“ yuicompressor”,则可以调用此变量,而不必总是一遍又一遍地输入完整路径。

java -jar %yuicompressor% myFile.js -o myFile.min.js --charset utf-8

为了使用java -jar执行JAR文件,您需要指定JAR文件的完整路径。

java -cp "<path to jar file dir>" -jar "<jarfilename>" args

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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