I have a small program where the user can enter a snippet of "real" java code in a text area, and then execute the code in order to perform some simple system tests. This program was made ages ago, and now I am curious if there are some new fancy ways to utilize the java platform in order to achieve the same thing (by for instance having the user entering Groovy in the text area, or perhaps supporting several script languages). I got curious when I read about java 7 having support for dynamically typed scripts in its virtual machine.
When developing your Java application, you do not need to choose the scripting language. If you write your application with the Java Scripting API (defined by JSR 223), then users can write scripts in any language compliant with JSR 223. See The Java Scripting API.
There are two main types of scripting languages: server-side and client-side.
If you really need to write a "script" and it needs to run on the Java runtime, I would recommend using Groovy. By "script" I mean, A scripting language, script language or extension language is a programming language that allows control of one or more software applications.
Scripting languages are used in system administration. For example: Shell, Perl, Python scripts etc. It is used in Games application and Multimedia. It is used to create plugins and extensions for existing applications.
You can use JavaScript support built-in from Java 6: Creating meta language with Java, see also ScriptEngineFactory
.
Also Spring framework has a Dynamic language support.
Note that the JVM 7 dynamic language support (via invokedynamic
) is irrelevant here. It is primarily targeted to dynamic languages compiled to JVM bytecode (like JRuby or Groovy).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With