On-the-fly, in-memory java code compilation for Java 5 and Java 6

前端 未结 6 2079
北荒
北荒 2020-11-27 18:17

How can I compile java code from an arbitrary string (in memory) in Java 5 and Java 6, load it and run a specific method on it (predefined)?

Before you flame this, I

6条回答
  •  我在风中等你
    2020-11-27 18:42

    Run inside a web container like Tomcat and first generate a JSP page, and then invoke it.

    This also allow you to get rid of the old class definitions by simply overwriting the JSP page instead of having your classloader slowly run full.

    Is the "in-memory" requirement due to speed or due to not changing the code base?

提交回复
热议问题