Extending on the FAQ -- Accessing your Jython code from Java

Submitted by: Josh Juneau

One of the most powerful features of Jython is that it is possible to access Jython code directly within a Java application. Many times performing simple tasks within Java can produce bloated code which is difficult to maintain. Jython gives you the ability to take that same code and reduce the complexity, producing easier to read and highly maintainable code.

There are two key components which must be followed in order to access jython code from java. One key behind accessing jython code from within a java appliation is the "jythonc" utility. This utility has the ability to compile jython code into a compatible java source. jythonc can also create jar files, freeze associated code modules, enable dependency tracking, and much more. The utilty is responsible for performing the task of creating a java source file from the designated jython (.py) module or class. It then calls a java compiler and creates class files from the produced java source.

As stated previously, jythonc has a number of available options.