Lin Ma
Lin Ma

Reputation: 10139

jython setup in Eclipse/PyCharm

Using Python 2.7 on Mac, and IDE is PyCharm. Need to use some Java functions inside Python script, and prefer to use import of Python, for example from com.a.b.c import fooFunc, so that I can use fooFunc in Python script as a Python function. The Java functions are defined in goo.jar.

My question is, where should I place the goo.jar file, so that Python/PyCharm could find the jar file?

Edit 1, add screen snapshot for PyDev for Jython project,

enter image description here enter image description here

Edit 2, add screen snapshot for auto-config error message,

enter image description here

Edit 3, cannot select installed jython interpreter from Eclipse, enter image description here enter image description here

Edit 4, can only select .jar file when configuring jython interpreter,

enter image description here

Edit 5, program runs ok but with red alert error messages from console,

enter image description here

enter image description here

Upvotes: 4

Views: 6572

Answers (1)

smac89
smac89

Reputation: 43088

Follow up on the comments above, yes if you are using pydev for Eclipse, then that's just the plugin that allows for writing python code with Eclipse. To install Jython, there are a number of guides out there, but it boils down to a two step process:

  1. Download and install Jython. The installation process will usually tell you where Jython is installed
  2. Next Configure your IDE to include the location of jython. As the JetBrains family of IDE's are very much the same, the way I added Jython to IntelliJ was File > Project Structure > SDK > + > Python SDK > Navigate to the Jython Binary

Also take some time to peruse the Jython Book.

Upvotes: 3

Related Questions