Possible Duplicate:
Null Pointer Exception while using Java Compiler API异常线程“main”显示java.lang.NullPointerException
我有这个计划的一些问题。
错误:
Exception in thread "main"
java.lang.NullPointerException at test.SimpleCompileTest.main(SimpleCompileTest.java:9)
计划:
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();
int compilationResult = compiler.run(null, null, null, fileToCompile);
if(compilationResult==0)
{
System.out.println("Compilation is successful");
}
else
{
System.out.println("Compilation has failed");
}
}
}
我想说的是,将三个空参数传递给一个函数并得到一个'NullPointerException'?嗯,让我们想想这个... – ApproachingDarknessFish