Created
September 23, 2016 23:14
-
-
Save jwagenleitner/bcbb118a5a76aee5c750a1f95f331cf3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.foo; | |
| import javax.tools.JavaCompiler; | |
| import javax.tools.JavaFileObject; | |
| import javax.tools.StandardJavaFileManager; | |
| import javax.tools.ToolProvider; | |
| import java.io.File; | |
| import java.util.Arrays; | |
| class JCTest { | |
| public static void main(String[] args) { | |
| String javaFile = "/tmp/MyClass.java"; | |
| JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); | |
| StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); | |
| Iterable<? extends JavaFileObject> compilationUnits1 = | |
| fileManager.getJavaFileObjectsFromFiles(Arrays.asList(new File(javaFile))); | |
| compiler.getTask(null, fileManager, null, null, null, compilationUnits1).call(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment