0
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");
    }
}
}

ERROR

Error

I am compiling SimpleCompileTest.java and getting this error. HELP!!!

rick
  • 913
  • 6
  • 13
  • 28

1 Answers1

0

I am not sure what the correct answer to your problem is, but you should take a look at this Example.

sandiego
  • 151
  • 1
  • 4
  • 10