Jython – Introduction

Jython :

Jython is a java implementation of python that combines expressive power with clarity.Jython is a powerful as well as simple because it uses Python’s syntax and Java’s environment.It allows using features of Python in Java environment or to import Java classes in Python codes and hence, it  is very flexible.  

Jython is freely available for both commercial and non-commercial use.

Jython

Advantages :

  • Embedded scripting – Java programmers can add the Jython libraries to their system to allow end users to write simple or complicated scripts that add functionality to the application.
  • Interactive experimentation – Jython provides an interactive interpreter that can be used to interact with Java packages or with running Java applications. This allows programmers to experiment and debug any Java system using Jython.
  • Rapid application development – Python programs are typically 2-10x shorter than the equivalent Java program. This translates directly to increased programmer productivity. The seamless interaction between Python and Java allows developers to freely mix the two languages both during development and in shipping products.

Example of Jpython :

#jpython Program 
from java.lang import System # Java import

print(‘Running on Java version: ‘ + System.getProperty(‘java.version’))
print(‘Unix time from Java: ‘ + str(System.currentTimeMillis()))