Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What fancy ways are there now to support scripting in java?

Tags:

java

scripting

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.

like image 357
Fredrik Israelsson Avatar asked Jan 09 '12 07:01

Fredrik Israelsson


People also ask

Can we use Java as scripting language?

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.

How many types of scripting languages are there?

There are two main types of scripting languages: server-side and client-side.

How do you write a JavaScript program?

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.

What are scripting languages where and why we do use them give a note?

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.


1 Answers

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).

like image 59
Tomasz Nurkiewicz Avatar answered Nov 10 '22 00:11

Tomasz Nurkiewicz