title: How can I integrate Java Compiler in Android Studio Application
body: <p>I was trying to integrate JAVA compiler into my application but was failing everytime.</p>
  <p>Below is my code which i tried testing but it too failed</p>
  <pre><code>    Looper.prepare();
      StringBuilder errors = new StringBuilder();
      PrintWriter writer =
              new PrintWriter(
                      new OutputStream() {
                          @Override
                          public void write(int p1) throws IOException {
                              errors.append((char) p1);
                          }
                      });
  
      Main main = new Main(writer, writer, false, null, null);
  
      Main.Logger logger = main.logger;
  
      File output = new File(outputPath);
      if(!output.exists()) output.mkdirs();
      final ArrayList&lt;String&gt; args = new ArrayList&lt;String&gt;();
  
      args.add(&quot;-classpath&quot;);
      args.add(&quot;[WHAT TO ADD HERE]&quot;);
      args.add(&quot;-log&quot;);
      args.add(outputPath+&quot;/logz.xml&quot;);
      args.add(&quot;-g&quot;);
      args.add(&quot;-1.8&quot;);
      args.add(&quot;-d&quot;);
      args.add(output.getAbsolutePath());
      StringBuilder classpath = new StringBuilder();
      if (classpath.length() &gt; 0) {
          args.add(&quot;-cp&quot;);
          args.add(&quot;[WHAT TO ADD HERE]&quot;);
      }
      args.add(&quot;-proc:none&quot;);
      args.add(&quot;-sourcepath&quot;);
      args.add(&quot; &quot;);
      args.add(javaPath);
  
      String[] argsArry = new String[args.size()];
      for (int i=0; i&lt;args.size(); i++){
          argsArry[i] = args.get(i);
      }
  
      main.compile(args.toArray(new String[0]));
  
      if(main.log.isEmpty()){
          main.log = &quot;EMPTY&quot;;
      }
  
      if (main.globalErrorsCount &gt; 0 | !output.exists() | output.listFiles().length != 0) {
          compilationListener.compilationFailed(main.log, errors.toString());
      }else{
          compilationListener.compilationSuccess(main.log);
      }
  </code></pre>
  <p>Here the compiler I am trying to add compiles all the java files which are present in the src directory</p>