I found this code:
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
if(compiler.run(null, null, null, fileName) != 0) {
System.err.println("Could not compile.");
System.exit(0);
}
However, this returns a NullPointerException
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at net.foxycorndog.foxy.compiler.Compiler.compile(Compiler.java:25)
at net.foxycorndog.foxy.compiler.Parser.parse(Parser.java:41)
at net.foxycorndog.foxy.Foxy$ActionHandler.actionPerformed(Foxy.java:99)
I read that the JRE does not include the ability to compile within a java program, but the JDK does.
I don't want a program that only works on a few computers that have had to manually set the path to the JDK library instead of JRE. With this in mind, is there any work around for this problem?
I would also like it to work over cross platform if possible.