Alex Rivera | Logout

Java as a scripting language for Java?

Asked 2012-12-06T16:03:28.270
16

Is it possible to use Java as a scripting language for java? Or maybe somehow compile java scripts into java binarries at runtime? I did tried to search but couldn't find anything comprehensive except for some hacks...

I have experience with other languages and for example for C# I used lua which was quite convenient but now I need to acheive the utmost performance as calls for scripts will be about 1.000.000 per frame.

So I figured that adapting java itself as a scripting language for java program should provide me the best performance and compatibility.

Any suggestions?

Edit
Report

1 Answer

6

The answer is 'Yes', you can use Java as a scripting language within a Java program itself. In addition, there are several other languages that can also be used for this purpose - Javascript, LUA, Groovy, Ruby, the list is long. Integration has been made much easier with the introduction of the javax.scripting API, which standardizes and greatly simplifies the processing of integrating third party scripting languages into Java programs. I would highly recommend reading up on the API and some tutorials on Oracles page.

http://docs.oracle.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html

answered 2012-12-06T16:09:21.807

Your Answer