6

Possible Duplicate:
Java Python Integration

There is some code written in Python and I need to use it from Scala. The code uses some native C. Is it possible to use this from Scala or Java without having to rewrite much?

I intend to use the code as a black-box without understanding, so I prefer not to look into it but rather to somehow generate a jar that I can import in my code.

Community
  • 1
  • 1
Jus12
  • 17,824
  • 28
  • 99
  • 157
  • There are tons of similar questions. E.g.: http://stackoverflow.com/q/1164810/891391 ? Have you try solutions from there? – yatul Jun 04 '12 at 13:57
  • None of the solutions suggested above are plug and play. I was hoping that there is a way to simply generate jar from existing python code. The code uses a lot of C bindings. – Jus12 Jun 04 '12 at 14:38
  • 1
    It is also frustrating to see search from Google gives mostly the solution of using java _from_ Python. However, I need the other way round. – Jus12 Jun 04 '12 at 14:44
  • Unfortunately, it's a duplicate, even if their is no satisfying answer... – Nicolas Jun 04 '12 at 14:58
  • You can have a look on Jep - https://github.com/ninia/jep/wiki/How-Jep-Works. Jep uses JNI and the CPython API to start up the Python interpreter inside the JVM. – gihanchanuka Oct 19 '17 at 08:21

1 Answers1

1

Why not try Jython?You directly compile python code to Java classes or call Python code from Java through interface.

Petr Mensik
  • 26,874
  • 17
  • 90
  • 115