views:

439

answers:

2

Can you run the YUICompressor from within a Java application?

I am new to Java programming so the answer may be obvious but it has alluded me.

A: 

It's written in java (+ rhino); It has api; Its tarball probably contains that api.

Look at it, add the jar into your project, employ it.

alamar
+1  A: 

Include the jar in your application and then look at the main function in ./com/yahoo/platform/yui/compressor/YUICompressor.java in the src directory of the zip file you download.

You can follow that to figure out the semantics of using the JavaScriptCompressor class within your own code.

It looks very straight forward.

Mark
Thank you for the info. Since I am new to Java, could you explain how to include the .jar file?
Lark
It has to be in your classpath. When you run your own application (java -jar myjar.jar) you might have a lib directory with your third party libraries (java -classpath lib -jar myjar.jar).Class path can also be set as an environment variable CLASSPATH -- a good tutorial on java classpath -- http://www.kevinboone.com/classpath.html
Mark