O'Reilly logo

Scripting in Java: Integrating with Groovy and JavaScript by Kishori Sharan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 5

image

Procedures and Compiled Scripts

In this chapter, you will learn:

  • How to invoke procedures written in scripts  from Java programs
  • How to implement Java interfaces in Nashorn script
  • How to compile Nashorn scripts and execute them repeatedly

Invoking Procedures in Scripts

In previous chapters, you have seen how to invoke scripts using the eval() method of the ScriptEngine. It is also possible to invoke procedures written in a scripting language directly from the Java program, provided the ScriptEngine supports procedure invocation.

A scripting language may allow creating procedures, functions, and methods. The Java Scripting API lets ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required