Java Reference
In-Depth Information
Chapter 24. Using Java with Other
Languages
Introduction
Java has several methods of running programs written in other languages. You can invoke a
compiled program or executable script using Runtime.exec() , as I'll describe in Running
an External Program from Java . There is an element of system dependency here, because you
can only run external applications under the operating system they are compiled for. Altern-
atively, you can invoke one of a number of scripting languages (or “dynamic lan-
guages”)—running the gamut: awk, bsh, Clojure, Ruby, Perl, Python, Scala—using
javax.script , as illustrated in Calling Other Languages via javax.script . Or you can drop
down to C level with Java's “native code” mechanism and call compiled functions written in
C/C++; see Calling Other Languages via Native Code . From native code, you can call to
functions written in just about any language. Not to mention that you can contact programs
written in any language over a socket (see Chapter 16 ), with HTTP services (see Chapter 16 ) ,
or with Java clients in RMI or CORBA clients in a variety of languages.
There is a wide range of other JVM languages, including:
▪ BeanShell, a general scripting language for Java.
Groovy is a Java-based scripting language that pioneered the use of closures in the Java
language ecosystem. It also has a rapid-development web package called Grails and a
build tool called Gradle (see Automating Dependencies, Compilation, Testing, and
Deployment with Gradle ) .
Jython , a full Java implementation of Python.
JRuby , a full Java implementation of the Ruby language.
Scala , a “best of functional and OO” language for the JVM.
Clojure , a predominantly functional Lisp-1 dialect for the JVM.
Search WWH ::




Custom Search