1

Presume I have Java code like this, available as a jar org.foo:bar:1.0.0 on Maven Central:

package org.foo.bar;
public class Calculator {
    
    public int sum(int a, int b) {
        return a + b;
    }

}

How do I set up a Python project's build, so in Python code I can call the equivalent of (new org.foo.bar.Calculator()).sum(3, 7)?

Related question (but not from a build perspective)

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • Sorry, I was a bit quick hitting the "dup" button. If that answers your question fine, otherwise please explain why not , and I will reopen the question. – GhostCat Dec 11 '20 at 08:48
  • Well, if you are using the Jython interpreter, yes. With CPython, you could look at libraries like https://github.com/jpype-project/jpype which acts as a bridge, so maybe not "direct" but as direct as you are going to get – juanpa.arrivillaga Dec 11 '20 at 08:50
  • @GhostCat The duplicated question doesn't cover the Maven Central artifact challenge, how to set up the build, which is my main question. I 've edited my title to make that clear. – Geoffrey De Smet Dec 11 '20 at 08:54
  • I still dont get the problem. You let maven fetch the dependency, then you have the class locally, then you use jython. Or you write your own java class that gives you a CLI interface to the class you want to call and invoke that via a subprocess call to java YourClass? – GhostCat Dec 11 '20 at 09:22

0 Answers0