执行文本文件中给出的java代码 [英] Executing java code given in a text file

查看:276
本文介绍了执行文本文件中给出的java代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文本文件中有一组java代码。我可以从文本文件中逐行读取并执行javascript的eval函数中的命令吗?提前致谢

I have a set of java code in a text file. Is it possible for me to read line by line from the text file and execute the commands as in eval function of javascript? Thanks in advance

推荐答案

尝试使用 BeanShell的。从介绍页面:

Try using BeanShell. From the introductory page:


什么是BeanShell?

What is BeanShell?

BeanShell是一个小的,free,embeddable
Java源代码解释器,带有对象
脚本语言特性,用Java编写
。 BeanShell动态
执行标准Java语法,
使用常见脚本
扩展它,例如松散类型,
命令和方法闭包,例如
Perl和JavaScript中的方法。

BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method closures like those in Perl and JavaScript.

您可以交互式使用BeanShell
进行Java实验和调试
,以及以新方式扩展应用程序
。脚本Java将
本身借给各种
应用程序,包括快速
原型设计,用户脚本扩展,
规则引擎,配置,测试,
动态部署,嵌入式系统,
甚至Java教育。

You can use BeanShell interactively for Java experimentation and debugging as well as to extend your applications in new ways. Scripting Java lends itself to a wide variety of applications including rapid prototyping, user scripting extension, rules engines, configuration, testing, dynamic deployment, embedded systems, and even Java education.

BeanShell很小且可嵌入,所以
你可以从你的Java
应用程序中调用BeanShell来执行Java代码
在运行时动态生成或在应用程序中提供
可扩展性。
或者,您可以使用独立的
BeanShell脚本来操作Java
应用程序;动态使用Java
对象和API。由于
BeanShell是用Java编写的,并且在与应用程序相同的VM中运行
,因此你可以自由地将
live对象的引用传递给脚本并返回
将它们作为结果。

BeanShell is small and embeddable, so you can call BeanShell from your Java applications to execute Java code dynamically at run-time or to provide extensibility in your applications. Alternatively, you can use standalone BeanShell scripts to manipulate Java applications; working with Java objects and APIs dynamically. Since BeanShell is written in Java and runs in the same VM as your application, you can freely pass references to "live" objects into scripts and return them as results.

简而言之,BeanShell是动态
解释的Java,加上脚本
语言和灵活的环境所有
归入一个干净的包裹。

In short, BeanShell is dynamically interpreted Java, plus a scripting language and flexible environment all rolled into one clean package.

这篇关于执行文本文件中给出的java代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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