title: Dynamically generating java class from a java program
body: <p>At the build(compile) time of my project I need to do code-generation for a java class. The generated java class is a java bean class with a set of getters and setters. At the build time I am getting the name of the class and names of variables. So what I need to do is dynamically generate the java bean from the information which I have. </p>
  
  <p>eg. At the compile time I am getting following data.</p>
  
  <pre><code>class-name=Test
  variable-name=aaa
  </code></pre>
  
  <p>So the generate class should look like following. </p>
  
  <pre><code>public class Test {
     public String aaa;
     public void setVar(String str) {
        this.aaa = str; 
     }
     public String getVar(){
        return this.aaa;
     }
  }
  </code></pre>
  
  <p>When I searched for a tool that I can use, I found Arch4j [1] interesting but the problem with that is it is not compatible with Apache 2.0 license. I am looking for a project/tool that is compatible with Apache 2.0 license.</p>
  
  <p>I would appreciate if someone can give me some insight on how I can do this. </p>
  
  <p>[1] - <a href="http://arch4j.sourceforge.net/components/generator/index.html" rel="noreferrer">http://arch4j.sourceforge.net/components/generator/index.html</a></p>