skip to main content
Skip header Section
Scripting in Java: Integrating with Groovy and JavaScriptDecember 2014
Publisher:
  • Apress
  • 901 Grayson Street Suite 204 Berkely, CA
  • United States
ISBN:978-1-4842-0714-7
Published:04 December 2014
Pages:
388
Skip Bibliometrics Section
Bibliometrics
Skip Abstract Section
Abstract

Scripting in Java teaches you how to use the Java Scripting API and JavaScript to execute scripts and take advantage of the features of a scripting language while developing Java applications. The book also covers topics that enable scripting languages to take advantage of Java features and the Java class library, including the new Java Collections and JavaFX 8 APIs. Most of the examples in this book use JavaScript on the Nashorn engine. Author Kishori Sharan will show you scripts in JavaScript to demonstrate its power and use in your Java applications. Some of the examples use the jrunscript and jjs command-line tools. Furthermore, debugging is discussed to equip you for situations when or if you encounter any issues with this kind of Java scripting. After reading and using this book, you will have most of what you need to do scripting in Java. What youll learn How to execute scripts and pass parameters to scripts What is the Java Scripting API as found in the new Java 8 How to write scripts in Nashorn and invoke procedures in scripts How to use compiled scripts and use Java in scripting languages How to use the new Java APIs, including JavaFX 8 and Collections in Nashorn How to implement a script engine How to use the jrunscript and jjs command-line tools Who this book is for This book is for those who have some experience with Java. Although it is not required, it would be helpful to have a basic knowledge of a scripting language before reading this book.

Contributors

Recommendations

Reviews

Claudiu Popescu

Java 6 introduced the Java scripting application programming interface (API) in the package javax.script. It contains a script engine (or interpreter) to evaluate scripts. The scripts can be written in languages such as Rhino JavaScript, Groovy, Jython, or JRuby. This book is a documentation of the Nashorn script language, which was introduced in Java 8 (Nashorn is the German word for rhino). The link between Java and JavaScript is reciprocal: Java can interpret JavaScript and JavaScript can use Java classes. The first part of the book describes the advantages of using the Java scripting API and contains examples of executing scripts in Java. The source code is available for download. The largest part of the book describes the Nashorn scripting language. The language is fully compatible with JavaScript, but contains other new elements. It also allows Java to use the functions declared in the scripting language. The next part shows how to use Java classes in a Nashorn script. The last chapters are about the command-line tools, integrating with JavaFX (the new Java graphical user interface (GUI) library intended to replace Swing), and debugging techniques. The book is well organized and rich in information. It is not intended for beginners to scripting, but for developers who have a good understanding of the various scripting languages and the relation between Java and JavaScript. Online Computing Reviews Service

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.