Wednesday, April 30, 2008

ClassNotFoundException vs. NoClassDefFoundError

ClassNotFoundException simply means that the class in not available in the CLASSPATH. You can see my previous post for tools to find the proper jar file containing the class. This exception is simpler to solve.

NoClassDefFoundError
is little tricky. This means that the class is available in the CLASSPATH and still its definition could not be loaded. The most common reason for this issue is some problem with the static block of the class in question. If you have the source check the static block of the class or if you don't have the source find the jar file in local classpath using jarscan and decompile using JAD and review the static block.

Finding a Jar for Class

Classpath issues are one of the most common issues while developing application using many open source libraries. Finding the right jar file and adding it to classpath could turn out to be nightmare if you don't use the right tools. Many developers end up adding all the jars they know to the CLASSPATH, in order to solve the problem. This is obviously not the right approach, but people still use it because they don't know an easy way to find the Jar file containing the class file.

You can use JarFinder or DocJar to search for the Jar files containing a particular class online. You can also JarScan to find the class in locally available Jar files.

Sunday, April 27, 2008

Regular Expression usefuls

If you use regular expression very regularly and you also happen to use eclipse then this plug-in is worth installing. And if you already don't know this is a library of regular expressions. The lib is very useful at times.

Tuesday, April 22, 2008

Automating interective application on UNIX

I was trying to write a shell script which would scp my files to another computer and execute some commands on that machine. My first thought was I won't be able to do this in shell script until I discovered expect. There is another tool called empty, which looked little better at first look, but I haven't tried it.

Command Line XML tool

I was looking for a tool to parse and query XML document from command line in UNIX environment. I needed this to be used in a shell script where I had to parse a XML file generated by another Application. I found XmlStarlet, after some googling, the tool is very useful to be used inside shell script as well as from command-line. Here is a good getting Started tutorial.