3/12/2007

Who set my CLASSPATH?

I never set CLASSPATH environment variable. Instead I always use the explicit -classpath or -cp options when running java, javac, javap, etc. The other day I was surprised to see a CLASSPATH environment variable is set:

C:\tmp> set CLASSPATH
CLASSPATH=.;C:\Program Files\Java\jre1.5.0_09\lib\ext\QTJava.zip

C:\tmp> dir "C:\Program Files\Java\jre1.5.0_09\lib\ext\QTJava.zip"
06/12/2006 09:57 AM 1,180,476 QTJava.zip
It seems when I installed apple's quicktime plugin, it automatically set this CLASSPATH in my environment. I don't like this. I always assume a clean environment when running any java applications. So I removed it:
C:\tmp> set CLASSPATH=

C:\tmp> set CLASSPATH
Environment variable CLASSPATH not defined
I can tolerate an installer modifying my PATH, but not CLASSPATH.

3/06/2007

A proposed README file in auto-loaded directories

In my previous post, I suggested not to put unused jar/zip files (*.jar, *.zip) in those directories that are automatically scanned and loaded. But how do we tell such a directory from regular ones? I think we need a quick way to know it without reading official documentations, if there is any.

I propose these magic directories contain a README file that looks like this:

All jar files (*.jar) in this directory are automatically loaded by the application server common classloader. The application server scans this directory in every 5 seconds by default. This scanning interval may be configured in config/server.xml. Note that this scan is non-recursive and any subdirectories are ignored.

WARNING: please do not put unused jar files in this directory to avoid class file conflicts.

For more information, please see the official application server documentation:
http://docs.my-application-server.com/classloader