Tuesday, February 1, 2011

Dynamic Java Classpath in UNIX

I've been playing "guess the dependency" with some Axis2 Java code all morning.  After encountering three or four NoClassDefFound exceptions, I'm rewriting my java command to dynamically list all of the jar libraries on the classpath.  Here's what I compiled from browsing some forums and blogs:

find /opt/axis2/lib -type f -name *.jar | \
sed ':a;N;$!ba;s/\n/:/g'