Book description
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.
Table of contents
- Cover
- Title
- Copyright
- Dedication
- Contents at a Glance
- Contents
- About the Author
- About the Technical Reviewers
- Acknowledgments
- Introduction
-
Chapter 1: Getting Started
- What Is Scripting in Java?
- Executing Your First Script
- Using the jjs Command-line Tool
- Printing Text in Nashorn
- Using Other Scripting Languages
-
Exploring the javax.script Package
- The ScriptEngine and ScriptEngineFactory Interfaces
- The AbstractScriptEngine Class
- The ScriptEngineManager Class
- The Compilable Interface and the CompiledScript Class
- The Invocable Interface
- The Bindings Interface and the SimpleBindings Class
- The ScriptContext Interface and the SimpleScriptContext Class
- The ScriptException Class
- Discovering and Instantiating ScriptEngines
- Summary
- Chapter 2: Executing Scripts
- Chapter 3: Passing Parameters to Scripts
-
Chapter 4: Writing Scripts in Nashorn
- Strict and Nonstrict Modes
- Identifiers
- Comments
- Declaring Variables
- Data Types
- Operators
- Type Conversion
- Statements
- Defining Functions
- The Object Type
- Binding Object Properties
- Locking Objects
- Accessing Missing Properties
- Serializing Objects
- Dynamically Evaluating Scripts
- Variable Scoping and Hoisting
- Using Strict Mode
- Built-in Global Objects
- Built-in Global Functions
- Summary
- Chapter 5: Procedures and Compiled Scripts
- Chapter 6: Using Java in Scripting Languages
-
Chapter 7: Collections
- What Is an Array in Nashorn?
- Creating an Array
- Deleting Array Elements
- Length of an Array
- Iterating Over Array Elements
- Checking for an Array
- Multidimensional Arrays
- Methods of the Array Object
- Converting an Array to a String
- Stream-Like Processing of Arrays
- Array-Like Objects
- Typed Arrays
- Using Lists, Maps, and Sets
- Using Java Arrays
- Arrays to Java Collections Conversions
- Summary
- Chapter 8: Implementing a Script Engine
- Chapter 9: The jrunscript Command-Line Shell
- Chapter 10: The jjs Command-Line Tool
- Chapter 11: Using JavaFX in Nashorn
- Chapter 12: Java APIs for Nashorn
- Chapter 13: Debugging, Tracing, and Profiling Scripts
- Index
Product information
- Title: Scripting in Java: Integrating with Groovy and JavaScript
- Author(s):
- Release date: December 2014
- Publisher(s): Apress
- ISBN: 9781484207130
You might also like
book
Java APIs, Extensions and Libraries: With JavaFX, JDBC, jmod, jlink, Networking, and the Process API
This book completes the Apress Java learning journey and is a comprehensive approach to learning Java …
book
Making Java Groovy
Making Java Groovy is a practical handbook for developers who want to blend Groovy into their …
book
Groovy for Domain-specific Languages - Second Edition
Extend and enhance your Java applications with domain-specific scripting in Groovy About This Book Build domain-specific …
book
Pages for iPad: Visual QuickStart Guide
Visual QuickStart Guides, designed in an attractive tutorial and reference format, are the quickest, easiest, and …