Nuclear Rooster

1Oct/072

Problems installing ANT: Exception in thread “main” java.lang.NoClassDefFoundError

I ran into some trouble installing ANT for use with the Flex2 SDK. I kept getting the following error:

[nick@dolores PIMP]$ ant
Buildfile: build.xml

default:

release:
     [echo] compiling the release version of pimp.swf
     [exec] Warning: -Xmx384m not understood. Ignoring.
     [exec] Warning: -jar not understood. Ignoring.
     [exec] Exception in thread "main" java.lang.NoClassDefFoundError: .opt.flex2_sdk.bin....lib.mxmlc.jar
     [exec]    at gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.5.0.0)
     [exec]    at _Jv_ThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.5.0.0)
     [exec]    at _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/libgcj.so.5.0.0)
     [exec]    at __gcj_personality_v0 (/home/nick/PIMP/src/main/actionscript/java.version=1.4.2)
     [exec]    at __libc_start_main (/lib/tls/libc-2.3.4.so)
     [exec]    at _Jv_RegisterClasses (/home/nick/PIMP/src/main/actionscript/java.version=1.4.2)

Everything I could find on google or apache.org pretty much just said "Check your JAVA_HOME and ANT_HOME varables". In the end they were right (kinda), but it was not very helpful at the time.

[nick@dolores PIMP]$ echo $JAVA_HOME && echo $ANT_HOME
/usr/java/jdk1.5.0_08
/opt/ant

Eventually I noticed the "java.version=1.4.2" line, which is a little odd, since I thought java 1.5 would be on the box.

[nick@dolores PIMP]$ /usr/bin/java -version
java version "1.4.2"
gcj (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

That's odd, why is 1.4.2 coming up? Lets check what Java stuff is here

[nick@dolores PIMP]$ sudo find / -name java
Password:
/usr/share/doc/db4-devel-4.2.52/ref/java
/usr/share/doc/libidn-devel-0.5.6/contrib/java
/usr/share/java
/usr/share/javadoc/java
/usr/java
/usr/java/jdk1.5.0_08/jre/bin/java
/usr/java/jdk1.5.0_08/bin/java
/usr/bin/java

So there are at least two executables, whats the deal?


[nick@dolores PIMP]$ ls -l /usr/bin/java*
lrwxrwxrwx  1 root root 22 Mar 13  2007 /usr/bin/java -> /etc/alternatives/java

Hmm. A symlink. Well, I don't really know what is going on with this box, so instead of messing around, I'll just set my path to look for Java 1.5 first.

export PATH=/usr/java/jdk1.5.0_08/bin:$PATH

[\code]

And it works! Hurray. Hope that helps. It's probably a good idea to look for existing Java and Ant files right up front, that way some crap like /etc/alternatives won't bite you in the butt for 2 hours.

Filed under: Uncategorized 2 Comments