title: CLASSPATH vs java.ext.dirs
body: <p>Is there any reason why to favor using (possibly very long) <code>CLASSPATH</code> variable to set which jars should be on classpath durign application run then to use the java 1.5+ property <code>-Djava.ext.dirs</code> which specifies whole directory(directories) of jars to be searched?</p>
  <p>To make it real-life example I have standalone java application with <code>lib</code> folder containing all dependent jars. So far the start script is setting all the (maybe 20) jars to <code>CLASSPATH</code> variable one by one. Since now my application archive  is generated by Maven I can't see in advance what the jar names would be (e.g. I change version of a JAR). Of course I can go through the <code>lib</code> dir in the startup script and add all jars found there to the <code>CLASSPATH</code> variable again. Or probably make maven to generate this script for me.</p>
  <p>Questions: Would it be OK and appropriate to replace all of this by simply setting the <code>java.ext.dirs</code> property to contain what it contains + my extra <code>lib</code> dir in my script? Any caveats hidden there?</p>
  <p>Thanks for replies.</p>