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?

1

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.
-1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.