issue with classpath set with current application source file in javax.tools.JavaCompiler?
<p>I have condition on web application where I am upload a .java source file and compiling this source based on the dependencies with jar files resides in WEB-INF/lib folder.</p>

<p>I am able to load this jar file by using this code and my file compile successfully and deploy .class in proper package inside WEB-INF/classes. with the help of this thread.
<a href="http://stackoverflow.com/questions/1563909/">How to set classpath when I use javax.tools.JavaCompiler compile the source?</a>.</p>

<pre><code>File[] javaFiles = new File[]{new File(fileToCompile)};
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();

DiagnosticCollector&lt;JavaFileObject&gt; diagnostics = new DiagnosticCollector&lt;JavaFileObject&gt;();
StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);

Iterable&lt;? extends JavaFileObject&gt; compilationUnits = fileManager.getJavaFileObjectsFromFiles(Arrays.asList(javaFiles));

List&lt;String&gt; optionList = new ArrayList&lt;String&gt;();
optionList.addAll(Arrays.asList("-classpath", System.getProperty("java.class.path")));
fileManager.setLocation(StandardLocation.CLASS_OUTPUT,
                Arrays.asList(new File(servletContextPath + WEB_CLASSES_PATH)));
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, optionList, null, compilationUnits);
</code></pre>

<p>the only problem I having here when I upload a .java source file which actually have an association with my current application java file this won't find the reference of this source and complaining the error.</p>

<p>Class A implements com.saif.WebDriverEventListener </p>

<p>package com.saif does not exist.</p>

<p>Any help would be appreciated.
Thanks,</p>
