0

I've got Xml files. They contain the structure that should be parsed in special kind of objects - with certain methods, fields and so on. Those Xml files should be provided in runtime for working application. So I need to parse it and generate java code that can be used in the application (loaded in runtime).

For parsing Xml I am using groovy. The application itself is not Groovy application but purely Java it's just that Xml processing is easier there.

But my question is - how should I generate Java classes? I can load them via classloader, but I need to generate .class files for him.

Should I generate .java classes and compile them (in a separate process) or should I create .class files directly? What libraries should I use for that?

lapots
  • 12,553
  • 32
  • 121
  • 242
  • 2
    Possible duplicate of [Creating classes dynamically with Java](https://stackoverflow.com/questions/2320404/creating-classes-dynamically-with-java) – Arthur Attout Mar 19 '18 at 21:39
  • FYI, using code formatting unnecessarily only makes it harder to read your question. – shmosel Mar 19 '18 at 21:40
  • Possible duplicate [How do you dynamically compile and load external java classes?](https://stackoverflow.com/questions/21544446/how-do-you-dynamically-compile-and-load-external-java-classes/21544850#21544850) – MadProgrammer Mar 19 '18 at 21:42
  • I decided to use `Byte Buddy` to generate `Class>` – lapots Mar 20 '18 at 10:47

0 Answers0