public static boolean isJavaCompilerAvailable(){
  JavaCompiler compiler=ToolProvider.getSystemJavaCompiler();
  return compiler != null;
}

public static boolean isJavaCompilerAvailable ( ) { JavaCompiler compiler = ToolProvider . getSystemJavaCompiler ( ) ; return compiler != null ; }
check if it is possible to use the java compiler .
