A continual pain when dealing with Java software is managing the CLASSPATH environment variable. I’m dealing with HtmlUnit, which depends on 12 jars. You can include everything in a big jar file if you’re deft enough with Ant, but a lot of projects – to include my personal ones – depend simply on a colon-delimited CLASSPATH of jars.
So here’s a little ditty that, fed a directory, does some magic with find(1) and searches the directory for any jar file, appending it to CLASSPATH. Behold:
MYJARS=/Users/alan/jars
export CLASSPATH=$CLASSPATH$(find $MYJARS
-name *.jar -exec printf :{} ';')
You can get fancy with find’s options if you want; there’s a shitload of them and the sky is the limit. I use printf(1) instead of echo(1), because it reliably prints its input sans-newline across most platforms.
Comment
Comment Visual Selection Blocks in Vim Command-line Campfire Client
Thanks for posting this. It was exactly what I was looking for.
— Joe Wright · Jun 18, 12:34 PM · #
Hey cool blog name! ;)
— Ben · Oct 19, 09:55 AM · #
Very handy, thanks!
— Ben · Jan 23, 07:04 PM · #