Categories:
/ (391)(rss)
   general (23)(rss)
      austin (4)(rss)
      random (5)(rss)
      scooter (4)(rss)
   tech (368)(rss)
      books (38)(rss)
      coding (10)(rss)
      java (160)(rss)
      jobs (8)(rss)
      mac (67)(rss)
      misc (55)(rss)
      net (16)(rss)
      ruby (4)(rss)
      xml (7)(rss)

JBoss: A Developer's Notebook JBoss 4.0 Guide cover

Recent Entries

Search

NetNewsWire blogroll

       
NormanRichards's Last.fm Weekly Artists Chart
Thu, 14 Aug 2003

::Java and shell scripts:: [/tech/java] (18:07)

Most Java coders I meet are IDE guys who are totally lost when it comes to doing anything outside of the IDE. I'm not necessarily talking about the dumb ones here. I regularly meet extremely bright developers who just haven't been exposed to the command line and don't realize how easy it is to solve problems by stringing together a few simple commands.

One of the questions I've heard often at work is which jar has the FooAdaptor class in it? I regularly need to track down classes, so I wrote a simple shell script called searchjars:

#!/bin/sh

term=$1
shift

for i in $*
do
   echo == $i
   jar tvf $i | grep -i $term
done

This can be invoked as searchjar FooAdaptor *.jar. Normally I wouldn't write a shell script for something so trivial, but I use it so often that I decided to do it.

Another common problem is tracking down those elusive NoClassDefErrors. At work we compile our application against struts 1.1 even though a few of the classes get deployed on old vendor proprietary version of tomcat that can only run struts 1.0. This hasn't been a problem until today when we started getting NoClassDefFoundError not being able to find ActionConfig on the struts 1.0 side. This class wasn't directly referenced in any of our classes, so we needed a way to find out which of the .class files was referencing it.

I knew that there had to be a reference to ForwardConfig in the class pool of one of the classes. So, I went to the build directory and used a combination of strings and find: find . -type f -exec strings -f {} \; | grep ForwardConfig.

Of course there are many other ways to solve the problem, but my point is that I think most Java coders have a very unhealthy lack of understanding of the tools at their disposal. If it's not a menu on the IDE, then they don't know how to do it. But there's just no substitute for the power of the command line.