Java 5中动态编译的选项 [英] Options for dynamic compilation in Java 5

查看:189
本文介绍了Java 5中动态编译的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了Janino之外,是否有任何选项可以在v5中实时编译和执行Java代码?我知道v6有编译器API,但我需要使用v5 VM。



我本质上需要一个字符串包含一个完整的Java类,编译和加载

解决方案

你想要的是类似 Janino 。我们已经使用了多年。你给它(接近标准)代码,它给你的类,所以你可以使用它们。它实际上有很多不同的模式,并支持1.5语法糖和自动装箱等。



如果你调用javac,不仅你必须准备好任何它做,你就必须处理将类放在正确的地方或做一个额外的类加载器。



Janino非常简单。它应该是你正在寻找的。

Are there any options other than Janino for on-the-fly compiliation and execution of Java code in v5? I know v6 has the Compiler API, but I need to work with the v5 VM.

I essentially need to take a string containing a complete Java class, compile it and load it into memory.

解决方案

What you want is something like Janino. We've used it for years. You give it (near standard) code and it gives you the classes so you can use them. It actually has quite a few different modes and supports the 1.5 syntactic sugar and auto-boxing and such.

If you call javac, not only will you have to be ready for anything it does, you'll then have to handle putting the class in the right place or making an additional classloader.

Janino is very easy. It should be exactly what you are looking for.

这篇关于Java 5中动态编译的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆