0

I'm currently working on a project involve Java and Python. Long story short, I followed some post on ways to access Python file from Java by packaging the file into a jython jar and import into the Java project.

Instead of using "java -jar jython.jar run.py" to call the run.py, anybody know if there is way to call the file from Eclipse (assuming I already add the jython.jar into to my build path?

Thank you so much!

5
  • William, I know we've already gone through this, but I think my answer below will really help you. Commented Jan 24, 2015 at 0:25
  • How is this William, below? Commented Jan 24, 2015 at 20:23
  • Be sure to mark solution below as answer. Commented Jan 26, 2015 at 20:53
  • Hello Malik, thank you for the screenshot and explanation. Now, the test.py file is in the source folder NOT in the jar that I important. What if I packaged it in the jython.jar? Can you still call it? Commented Jan 26, 2015 at 21:58
  • Why would you do this, if possible? Right click your project in Eclipse and export. You can then export to a runnable JAR that can contain your entire project including both of those files. Commented Jan 26, 2015 at 22:06

1 Answer 1

0

Drag this image in the entry bar in your browser. The PythonInterpreter executes test.py.

Jython

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

10 Comments

How is this William? I've tried you walk you through completely.
Hello Malik, really appreciate you spend time on explaining this. I know how to add jar to build path and use jython jar. My real question is, I have package a python file in the jar, say print hello world, it's not part of the jython.jar. Through command line I can do this "java -jar jython.jar print.py" and it will call the python. Now I want to know how to do this in Eclipse...Thanks for your effort.
I believe so but why would you package script.py in jython.jar? You can export your whole Eclipse project to a jar as is.
Yes, but in your case, if you export your project to a jar, you won't be able to call test.py anymore because test.py will be in a zip file, your src/test.py won't work.
I think it will work src/test.py will just be contained within the JAR.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.