0

So I have a Python script that look like this:

def methodOne():
    print("Hello I am the first method")

def methodTwo():
    print("Hello I am the second method")

And I have a simple Java script like this:

public class helloworld {

    public static void main(String[] args) {
        //Here I want to call the Methods that are in the Python script
    }

}

But I can´t figure out how I could call those methods in the Java file. Is there a way to do this?

2 Answers2

0

You can use Java Runtime. exec() to run python script, As an example first create a python script file using shebang and then set it executable

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 05 '23 at 20:32
-1

Try this my friend https://pythonhosted.org/javabridge/java2python.html it might help you with the solution. But I never tried my self