1
votes

I am new to both Python and Jython. I am just wondering if is possible to use Python to execute a Jython script and get its result.

The reason is the code was previously done by another person and I do not want to go changing or messing with every single thing that has compatibility issue with Jython. because I just need to pass some data to a Java class and receive its return result.

I try using subprocess but i kept getting a error stating (The system cannot find the file specified)

from subprocess import Popen, PIPE, STDOUT
p = Popen(['Jython', 'test.py'], stdin=PIPE, stdout=PIPE, stderr=STDOUT)
1
How do you run test.py with Jython from the command-line? Does it succeed? - pts

1 Answers

2
votes

There are two possible problems here:

  • change Jython to jython as the terminal/python are case sensitive.
  • specify the absolute path to your test script '/{PATH TO TEST SCRPIT}/test.py'