Jython Essentials
By Samuele Pedroni, Noel Rappin
March 2002
Pages: 300
ISBN 10: 0-596-00247-5 |
ISBN 13: 9780596002473




(4) (Average of 4 Customer Reviews)


Description
Jython is an implementation of the Python programming language written in Java, allowing Python programs to integrate seamlessly with any Java code. The secret to Jython's popularity lies in the combination of Java's libraries and tools with Python's rapid development capabilities. Jython Essentials provides a solid introduction to the language, numerous examples of Jython/Java interaction, and valuable reference material on modules and libraries of use to Jython programmers.
Full Description
Jython is an implementation of the Python programming language written in 100% pure Java, so it runs under any compliant Java Virtual Machine. The secret to Jython's popularity lies in the combination of Java's libraries
and tools with Python's rapid development capabilities. With Jython, you can write Python programs that integrate seamlessly with any Java code. And like Python, Jython can be used interactively, so you can get immediate results as you are programming.
Jython Essentials provides a solid introduction to the Python language, offering a brief but thorough tour of the Python concepts you'll need to understand to use Jython effectively. The book makes frequent comparisons
between Python and Java, with special emphasis on the different object-oriented semantics of the two languages, so Java programmers can quickly get up to speed with Jython.
Jython Essentials also covers the various ways in which Jython and Java can interact. For example, Jython code can create instances of pre-existing Java classes and call methods in those instances. You can write Jython classes that are direct subclasses of existing Java classes
and use introspection to discern the capabilities of JavaBeans components. This book provides examples of using Jython with existing Java libraries, including the Swing GUI toolkit, the JDBC database API, the Servlet API, and various XML tools. And finally, the book shows how
Jython can be used as a scripting language within a Java program.
With Jython Essentials, you have everything you need to start creating applications that mix the best of Python's interactivity and Java's robust libraries.
Featured customer reviews

A little confusion by Anonymous Reader,
July 31 2006
Submitted by Anonymous Reader [
Respond |
View]
A correct code would be:
import Y
y = Y.Y()
not
Import Y
y = Y()
More examples please,
July 30 2004
Submitted by Anonymous Reader [
Respond |
View]
I thought overall it was well laid out and covered most of the points, but thought it would have been far better if there had been more examples included, and any gotchas.
For example:
Putting the following into Y.py
class Y:
def __init__(self):
print "foo"
then in the console doing:
import Y
y = Y()
gives the following error:
Traceback (innermost last):
File "<console>", line 1, in ?
TypeError: call of non-function (module 'Y')
but it works ok if you type the class definition into the console.
This sort of problem could have been gone into in the book - there are other examples.
The book assumes that one knows exactly how to do things in python, and that everything will work just fine 1st time
Jython Essentials Review,
November 24 2003
Submitted by Orlin Melstrand
[
Respond |
View]
This book is similar to the other O'Reilly books that have become popular for their conciseness and content--no fluff here. This is the type of book most useful to someone who wants or needs to concentrate on the subject and learn the technology. (It is not a classroom textbook, with exercises, tests, and so forth, though it does have short examples, which are better for learning than long ones, in my opinion.) The book will probably be most accessible to readers who are familiar with core Java. Familiarity with Python would be helpful, but should not be necessary--a three-chapter introduction to Python is included. It should be of interest to Java and Python programmers, and others interested in scripting applications.
Appendices are included on Jython installation, and comparisons between Jython and Python and between Jython and Java. A nice little surprise is a section on the use of PyUnit, the Python counterpart to JUnit, for unit testing, which also includes a discussion on compiling Jython.
The authors explain how to use Java from Jython, including type conversions, and how to subclass Java classes from Jython code. One chapter is devoted to a discussion of Java reflection and working with JavaBeans, and the use of Python reflection. Another includes examples illustrating how to construct an HTML browser and an HTML source browser, using Swing.
Another chapter includes a short discussion on each of JDBC (actually zxJDBC, the Python version), servlets, and parsing XML, with illustrative examples. The parsing examples use SAX, DOM, and JDOM, respectively; the zxJDBC example uses MySQL. The book also includes a brief discussion
of regular expressions, with a couple of short examples.
Finally, there is a chapter explaining how to use Jython from Java, which allows the embedding of a Jython interpreter in a Java program.
Notes: Examples run on Jython 2.0 or higher and jdk1.2 or higher.
The book has a web site with code samples for download, and errata.
Read all reviews
Jython Essentials Review,
April 23 2002
Submitted by Scott Shattuck
[
Respond |
View]
Overall a very good effort, particularly if you're looking to understand some of the nitty gritty details of Jython. The major missing element however is any coverage of threading/synchronization. Java programming often relies heavily on threading and there is no coverage of how to do it in Jython in this book.
I'd suggest this as a companion guide to New Riders' "Jython For Java Programmers". Each is an excellent book and they complement each other well. Between the breadth of coverage in the NR title and the depth of detail in Jython Essentials you should be outcoding straight Java programmers in no time ;).
Media reviews
"'Jython Essentials' is a concise, detailed walk through of the state of Jython, how to embed Jython, how to use Jython to simplify JavaBeans and Swing programming as well as using PyServlet to make your servlets programming a great deal simpler...In examining this valuable scripting extension to the Java programming model, 'Jython Essentials' fills a much needed gap in the information surrounding this language."
--James Richards, GameJUG, August 2002
Read all reviews