Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Java Compiler API NullPointerException
- +---- src
- +----- package
- +------ Compile.java
- +
- +
- +---- temp
- +----- anotherpackage
- +------ Temp.java (file to compile)
- public static void compile(URI path, InputStream is, OutputStream os, OutputStream err) throws IOException {
- SimpleJavaFileObject source = new CustomJavaFileObject(path, Kind.SOURCE);
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- JavaCompiler.CompilationTask task = compiler.getTask(new PrintWriter(err), null, null, null, null, Arrays.asList(source));
- task.call();
- }
- class CustomJavaFileObject extends SimpleJavaFileObject {
- protected CustomJavaFileObject(URI uri, Kind kind) {
- super(uri, kind);
- }
- }
- java.lang.NullPointerException
- at package.Compiler.compile(Compiler.java:20)
- at package.Interactive.main(Interactive.java:19)
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
Add Comment
Please, Sign In to add comment