title: Setting java classpath for lucene on a mac
body: <p>I downloaded the lucene jars and then added them to the CLASSPATH variable via my .bash_profile, the paths to the jars display correctly in the terminal.</p>
  
  <pre><code>export CLASSPATH=/Users/dk/lucene-3.4.0/lucene-core-3.4.0.jar
  export CLASSPATH=$CLASSPATH:/Users/dk/lucene-3.4.0/contrib/demo/lucene-demo-3.4.0.jar
  
  echo $CLASSPATH
  /Users/dk/lucene-3.4.0/lucene-core-3.4.0.jar:/Users/dk/lucene-3.4.0/contrib/demo/lucene-demo-3.4.0.jar
  </code></pre>
  
  <p>However, java still complains to me when I try to run the demo:</p>
  
  <pre><code>java org.apache.lucene.demo.IndexFiles -docs .
  
  Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/demo/IndexFiles
  Caused by: java.lang.ClassNotFoundException: org.apache.lucene.demo.IndexFiles
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
  ......
  </code></pre>
  
  <p>I was able to follow this exact procedure to get the lucene demo working on an ubuntu machine, now I just want it to be able to run on my mac. It seems there are similar questions floating around stackoverflow but none of them seem to answer this question.</p>