0

I have a String which contains the source code of an entire java class. My intention is to create a new class in another project folder using the code in this String. All this is to be done by code, not manually.

Is this possible in Java?

einpoklum
  • 118,144
  • 57
  • 340
  • 684
Hayabusa
  • 41
  • 1
  • 5

2 Answers2

3

Since you are using String, I'm assuming you are talking about a class in Java source code form. If you are targeting JRE 1.6 or higher, you can use the JavaCompiler interface for turning this source code into a compiled Java class.

See Java API documentation.

Tony the Pony
  • 40,327
  • 71
  • 187
  • 281