0

I've been trying to excute a Python script from Java or Coldfusion framework (which runs on a JVM), The most documented solution is Jython but it only runs on Python 2.7 which is a problem because I need to use some librairies that runs only on Python 3 .

The JEP (https://github.com/ninia/jep) / JPY (https://github.com/bcdev/jpy) repositories on github really fits my needs but they are not quite responsives to the Github issues .

Has anyone ever done something similar before ?

Klodovsky
  • 21
  • 2
  • Take a look here:https://github.com/mkopsnc/keplerhacks/tree/master/python You have there a sample where you can go to Python via JNI. In case you don't need tight integration you can always run script from Java and either read stdout/stderr or create some output data that will be read once Python is done with it's work. – Oo.oO Nov 25 '20 at 12:43

2 Answers2

0

Unless you really need to embed jython into your application, you may execute a system command (e.g. run a python script) from Java using the method described here.

Curtis
  • 548
  • 3
  • 13
  • Yes sir I know about that, it's just not the best way to adapt especially when working around a huge project, JEP/JPY repositories on Github are what I was looking for, and everything works perfectly so far ;) Thanks for your comment ! stay safe. – Klodovsky Nov 25 '20 at 12:16
0

The issue with Jep wasn't any syntax error, for example jep.eval(' some Python code'); was supposed to run that Python code in Java, If your system environement is well configured then what's left to do is to redirect use Jep's Python redirect_stream() function to redirect the flow of your IDE, worked for me finally .

Klodovsky
  • 21
  • 2