我有一个获取 html 文件内容的应用程序。
假设页面的文本是:
String[] arr = new String[] {"!","@","#"};
for (String str : arr) {
write(str);
}
我能否以某种方式编译此文本并在我的应用程序中运行代码?
谢谢
最佳答案
使用Janino .它是一个 Java 运行时内存编译器。比 BCEL 之类的要容易得多。
来自主页:
“什么是贾尼诺?
Janino is a super-small, super-fast Java™ compiler. Not only can it compile a set of source files to a set of class files like the JAVAC tool, but also can it compile a Java™ expression, block, class body or source file in memory, load the bytecode and execute it directly in the same JVM. Janino is not intended to be a development tool, but an embedded compiler for run-time compilation purposes...
关于java - 可以将字符串编译为代码吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11925497/