title: how to create a java class file from context of a String
body: <p>I want to achieve providing a string like = "System.out.println(1)",while running program to dynamicly create a class having this codes as a function.</p>
  
  <p>i have tried org.apache.commons.jexl2 package,but it seems to me a beginner it only work on a single expression</p>
  
  <pre><code>public static Object invokeMethod(String jexlExp, Map&lt;String,Object&gt; map){
      JexlEngine jexl=new JexlEngine();
      Expression e = jexl.createExpression(jexlExp);
      JexlContext jc = new MapContext();
      for(String key:map.keySet()){
          jc.set(key, map.get(key));
      }
      if(null==e.evaluate(jc)){
          return "";
      }
      return e.evaluate(jc);
  }
  public static void main(String[]args){
      Map&lt;String,Object&gt; map=new HashMap&lt;String,Object&gt;();
      map.put("money",3000);
      String expression="{if(money==3000)return 30000}";
      Object code = invokeMethod(expression,map);
      out.println(code);
  
  }
  </code></pre>