ToolProvider.getSystemJavaCompiler() returns null - usable with only JRE installed?

java, javac

Solution

ToolProvider.getSystemJavaCompiler() is not available.

Is tools.jar missing from the classpath?

`Set class path to the tools.jar` file which can found in jdk\jre directory.

`System.setProperty("java.home", "C:\\Program Files\\Java\\jdk1.7.0_02");`

Problem

I am trying to use the JavaCompiler class: - http://docs.oracle.com/javase/6/docs/api/javax/tools/JavaCompiler.html When I call ToolProvider.getSystemJavaCompiler() it returns null. I think this is because I'm using a JRE instead of a JDK. The problem is I want it to run on all platforms regardless of weather the user is using a JRE or a JDK. If anyone knows how to fix this, or an alternative method to use please comment. Any help would be appreciated.

Original source

Related problems