title: using java api for compilation
body: <pre><code>MyClass.java:
  
  package test;
  public class MyClass {
   public void myMethod(){
       System.out.println("My Method Called");
   }
   }
  
    Listing for SimpleCompileTest.java that compiles the MyClass.java file.
  
    SimpleCompileTest.java:
  
    package test;
    import javax.tools.*;
     public class SimpleCompileTest {
    public static void main(String[] args) {
     String fileToCompile = "test" + java.io.File.separator +"MyClass.java";
     JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); //Line 6
     int compilationResult =  compiler.run(null, null, null, fileToCompile);
              if(compilationResult == 0){
          System.out.println("Compilation is successful");
      }else{
          System.out.println("Compilation Failed");
      }
  }
  }
  </code></pre>
  
  <p>ERROR</p>
  
  <p><img src="https://i.stack.imgur.com/sTxDF.jpg" alt="Error"></p>
  
  <p>I am compiling SimpleCompileTest.java and getting this error. HELP!!!</p>