Where can I find a list of available JSR-223 scripting languages? [closed]
Asked Answered
W

4

45

I need a JVM-based scripting language for my app and would like to see what else is out there besides Groovy, Ruby, and Python.

Google keeps pointing me to a dead page at http://scripting.dev.java.net/

Winifield answered 7/8, 2012 at 2:7 Comment(2)
The correlation of "useful" and "off-topic" questions in SO is 0.99Winifield
HDave, SO has long since gone off the rails regarding its pedantry. The other stackexchange sites are considerably less silly.Noranorah
H
33

This is not a official list, but you can start here: http://en.wikipedia.org/wiki/List_of_JVM_languages

Rhino (JavaScript) is implemented in the Oracle JDK/JRE by default.

With this code you can see what scripting languages are available in your JDK:

import java.util.*;
import javax.script.*;

public class A {

    public static void main( String[] args ) {

        ScriptEngineManager mgr = new ScriptEngineManager();
        List<ScriptEngineFactory> factories = mgr.getEngineFactories();

        for (ScriptEngineFactory factory : factories) {

            System.out.println("ScriptEngineFactory Info");

            String engName = factory.getEngineName();
            String engVersion = factory.getEngineVersion();
            String langName = factory.getLanguageName();
            String langVersion = factory.getLanguageVersion();

            System.out.printf("\tScript Engine: %s (%s)%n", engName, engVersion);

            List<String> engNames = factory.getNames();
            for(String name : engNames) {
                System.out.printf("\tEngine Alias: %s%n", name);
            }

            System.out.printf("\tLanguage: %s (%s)%n", langName, langVersion);

        }

    }

}

This example was obtained here: http://www.oracle.com/technetwork/articles/javase/scripting-140262.html

You may want to try Lua too. Take a look here: how can I embed lua in java?

Hime answered 7/8, 2012 at 2:22 Comment(4)
I didn't get the connection between JVM languages and scripting languages. BTW -- I ran the class, but the only one it returned was Rhino. Still nice to have the code...thanks.Winifield
@HDave: There are languages for the JVM that are scripting languages and languages that are not. Yep, by default there is only Rhino in the JRE.Hime
There is no guarantee that JavaScript is available in your JRE, Oracle just happens to ship it.Imputation
This doesn't answer the question; JSR-223 compliant languages are only a subset of those languages that can run on the JVM.Tryout
V
31

The old page is located here https://web.archive.org/web/20070610234337/https://scripting.dev.java.net/

The ones hosted on the JSR-223 project page can be browsed at https://web.archive.org/web/20140909141915/https://java.net/projects/scripting/sources/svn/show/trunk/engines but the list is:

JSR-223 script engines

  • AWK
  • BeanShell
  • ejs
  • FreeMarker
  • Groovy
  • Jaskell
  • Java
  • JavaScript
  • JavaScript (Web Browser)
  • Jelly
  • JEP
  • Jexl
  • jst
  • JudoScript
  • JUEL
  • OGNL
  • Pnuts
  • Python
  • Ruby
  • Scheme
  • Sleep
  • Tcl
  • Velocity
  • XPath
  • XSLT

JSR 223 script engines maintained elsewhere

  • JavaFX Script
  • ABCL
  • AppleScript
  • Bex script
  • OCaml Scripting Project
  • PHP
  • PHP (another one)
  • Python
  • Smalltalk
  • CajuScript
  • MathEclipse
  • Kotlin

For download links look in the index.html I mention above. For any of the java.net projects just remove the dev so scripting.dev.java.net becomes scripting.java.net. You might have to browse in a repo for the old web pages.

One notable thing, the JavaScript engine (Rhino) is being completely rewritten for Java 8. The new name is Nashorn. For more see: http://openjdk.java.net/projects/nashorn/

Venenose answered 13/2, 2013 at 22:28 Comment(7)
The links given no longer work: "We're sorry the java.net site has closed." I found a mirror here: github.com/scijava/javax-scriptingCalliopsis
Notice freemarker is waiting for contribution on JSR-223 freemarker.apache.org/contribute.htmlAnaya
Note that Nashorn is deprecated for removal in JDK 11. You will still be able to ask for javascript from the JSR-223 scripting API because of Rhino but I wouldn't rely on Nashorn for new projects.Caribbean
The list shows Java. Can we use Java as scripting language too?Oops
@Caribbean the point of JSR-223 is you don't depend on a specific implementation. The new one replacing Nashorn is GraalVM. It's not going back to Rhino.Raouf
@Raouf there are no plans to replace Nashorn in the OpenJDK. GraalVM would be an external dependency. An excellent one, and it provides migration from Nashorn and extensions. But it tells you a lot about the empty promise of JSR-223, that there are extensions to migrate. And that's before we get into all the docs and code examples that ask for Nashorn by name. My point stands for the unwary. In fact, just skip Nashorn and JSR-223 and use truffle polyglot.Caribbean
ScriptEngine languages are self-registering via the java.util.ServiceLoader mechanism (Service Discovery / Service Provider Interface). This means that in a library in META-INF\services a file is created that points to an implementation of the ScriptEngineFactory interface. It depends on the specific language if they add this in the "core" jar of the scripting language, or if this is done via a separate jar. For example beanshell add this in the core org.apache-extras.beanshell:bsh jar since version 2.0. Adding this jar to your classpath is sufficient to be able to use in ScriptEngine.Overwhelm
P
2

I'm not aware of a comprehensive list.

However it is worth pointing out that you can use pretty much any embeddable JVM language for scripting purposes as long as it supports dynamic compilation / execution at runtime. It doesn't really matter if it is JSR233 or not.

For example, I use Clojure for scripting (with a custom DSL) in a few of my apps.

I've not tried it myself, but I think you could also use Scala: scala as scripting language

FWIW, my personal choices would be:

  • Clojure for expressive power / DSL capabilities (if you are using the scripting capability yourself or with an expert team)
  • Groovy if your main goal is ease of use for end users (because of simplicity and similarity with Java)
Proleg answered 7/8, 2012 at 2:23 Comment(0)
B
1

also i found this page: http://java-source.net/open-source/scripting-languages

they are mentioning other script languages, like a Basic like called JBasic, LUA, LuaJava... ePascal and many other

Biomass answered 1/2, 2015 at 4:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.