I'm new to both gcj and java, so forgive me if I'm missing something obvious. I'm trying to compile YUICompressor using gcj, and I'm getting an error that it can't find the main class. I have:
~/java/yuicompressor.2.4.8> gcj --main=YUICompressor -g -o yuicompress build/yuicompressor-2.4.8.jar
/tmp/ccbNVkUt.o: In function `main':
/tmp/ccbuUbZw.i:11: undefined reference to `YUICompressor::class$'
collect2: ld returned 1 exit status
I know that the YUICompressor class is within the jar file, so I'm not understanding why gcj is not seeing it:
~/java/yuicompressor.2.4.8> jar -tf build/yuicompressor-2.4.8.jar | grep YUICompressor.class
com/yahoo/platform/yui/compressor/YUICompressor.class
~/java/yuicompressor.2.4.8> find . -name YUICompressor.java -exec grep -H "\bmain\b" {} \;
./src/com/yahoo/platform/yui/compressor/YUICompressor.java: public static void main(String args[]) {
./build/build_tmp/com/yahoo/platform/yui/compressor/YUICompressor.java: public static void main(String args[]) {
The YUICompressor.jar file seems to work fine if invoked from java, but I want to distribute this as a binary which is not dependent on java being installed on the target machines. Any suggestions are appreciated.
You need to tell gcj the whole class name, including the package, which is (in this case) com.yahoo.platform.yui.compressor.YUICompressor
.