title: How to set up classpath of JavaCompiler to multiple .jar files using wildcard
body: <p>I am using <code>JavaCompiler</code> of <code>javax.tools</code> to compile some java code and I am trying to use wildcard in my <code>classpath</code> in order to include all the <code>.jar</code> files but I fail.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    String classpath = "C:\tomcat6\webapps\myapp/WEB-INF/lib/javax.ws.rs-api-2.0-m10.jar;"
  + "C:\\tomcat6\\webapps\\myapp/WEB-INF/lib/javax.persistence-2.1.0.jar";
  
      Iterable&lt;String&gt; options = Arrays.asList("-d", classesBaseDir,
                      "-classpath", classpath);
  
      JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager,
                      diagnostics, options, null, file);
      boolean result = task.call();
  </code></pre>
  
  <p>The code above works just fine. But when I am trying to change the <code>classpath</code> to</p>
  
  <pre><code>String classpath = "C:\\tomcat6\\webapps\\myapp/WEB-INF/lib/*";
  </code></pre>
  
  <p>it fails with  </p>
  
  <pre><code>    compiler.err.doesnt.exist|package javax.ws.rs does not exist
  ...
      symbol:   class GET
        location: class com.my.oasis.resources.TestClass
      09/04/2014 14:27:09:030 | COMPILER_DIAGNOSTIC | compileResource() - compiler.err.cant.resolve.location|cannot find symbol
      ...
  </code></pre>
  
  <p>I have also tried the following alterations</p>
  
  <pre><code>String classpath = "\"C:\\tomcat6\\webapps\\myapp/WEB-INF/lib/*\"";
  String classpath = "'C:\\tomcat6\\webapps\\myapp/WEB-INF/lib/*'";
  </code></pre>
  
  <p>but none of them worked. Any ideas?</p>
  
  <p>Thanks</p>
  
  <p><strong>Note:</strong> the reason why the path includes slashes and backslashes is because the my program identifies the environment in runtime and auto completes the path. </p>
  
  <p><strong>Edit:</strong> I am using tomcat 6 and java 1.7.0_21</p>