0

Is there any way to programatically generate class files from .java files present in a folder. There are examples using JavaCompiler.CompilationTask for compiling single java files.But i need to to generate class file from multiple couples .java codes(generated from JAXB gen).

soumitra chatterjee
  • 2,268
  • 9
  • 26
  • 48
  • possible duplicate of [Using Java Compiler API to compile multiple java files](http://stackoverflow.com/questions/9112640/using-java-compiler-api-to-compile-multiple-java-files) – Vince Nov 18 '14 at 18:53
  • Already tried...not working..throwing this exception: Exception in thread "main" java.lang.IllegalArgumentException: All compilation units must be of SOURCE kind at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:183) at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:68) at MyGrp.com.myArtifact.Main.compile(Main.java:154) at MyGrp.com.myArtifact.Main.main(Main.java:121) – soumitra chatterjee Nov 18 '14 at 18:58
  • Can't do much with that stacktrace if you don't show code. Edit a [MVCE](http://stackoverflow.com/help/mcve) into your question so we can see how you are attempting to do it. Also, edit in that the duplicate doesn't help because (enter reason here; in your case, exception is thrown, edit the stacktrace into your question as well) – Vince Nov 18 '14 at 19:02

1 Answers1

0

Use Runtime.getRuntime().exec("javac ...");

ControlAltDel
  • 33,923
  • 10
  • 53
  • 80