2/27/2007

Don't copy jar files in auto-loaded directories

Jar files in some directories are automatically loaded into JVM in some applications. Some examples of these magic directories are, common/lib and shared/lib in Tomcat, $JAVA_HOME/jre/lib/endorsed, $JAVA_HOME/jre/lib/ext, etc. This can ease the task of classpath management, to some extent. But we should also be very careful while doing anything in these directories. Specifically, do not put any unused *.jar files in these directories, since they will also be loaded by java runtime and may cause conflict.

Sometimes I need to try a different version of a jar. I rename the old jar to foo-02272007.jar and copy the new jar over. In an auto-loaded directory, this may cause nasty random errors due to conflict between 2 versions of the same jar. I should really back up the old jar as foo.jar.20202007 without a .jar extension to exclude it from auto-loading.

1 comment:

Shivani said...

wonderful blog :)