Demonstrates the use of needing jython/python with a number of libraries.
This project demonstrates the Maven-Jython compile plugin.
To see or get the code, look at the source repository.
The resulting jar should start python code, that interacts with a java class and loads a 3rd party python library (nose)
We have a Java class, FibSequenceCalc, which generates the Fibonacci sequence.
We put our python code as a library, "fibcalc", into Lib. The main() function lists as many Fibonacci numbers as the library nose has entries.
InitJython loads up jython in various ways.
In the pom, we declare nose as a needed library in the configuration-section of the maven-jython-compile-plugin.
run
mvn package
which should give you the jar-with-dependencies.jar in the target folder. Run it with
java -jar <filename>.jar <args>
Without arguments, you will get a python console.
With "eval", you can evaluate your own code in the second argument.
With "run", you can run a custom python script.
With "script", the integration of python as a Java Scripting Engine is demonstrated.
To find out more, look at the source code.
If a jython installation is already on the users computer, one might also call
jython -jar my.jar
This executes the __run__.py code.