MyClass.java:
package test;
public class MyClass {
public void myMethod(){
System.out.println(\"My Method Called\");
}
}
Li
I was having the same problem
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
was returning null. Even after using
System.setProperty("java.home", "C:\\Program Files\\Java\\jdk1.8.0_31");
was returning null.
However the issue was simple as this code is in the Tools.jar found in Java\jdk1.8.0_31\lib if you are using JDK. what i did was to go to project-->properties-->Java Build Path-->order and export--> and moved tool.jar to the top of other JRE and projects.
This helped me get rid of null hope this help you as well.Happy compiling...:-)