Skip to content
A bi-directional Python-Java bridge used to embed Java in CPython or the other way round.
Python C Java Other
Branch: master
Clone or download
Latest commit c5aee57 Nov 5, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ci upload wheels to bc FTP server Feb 8, 2018
doc Docs for setPythonHome Jun 22, 2018
pysobug rename Aug 19, 2014
src PyObject shall not be Serializable. This is a reverse of pull request #… Sep 9, 2018
.gitignore
.travis.yml upload wheels to bc FTP server Feb 8, 2018
CHANGES.md
LICENSE.txt Using Apache 2.0 license (issue #60) Sep 10, 2015
MANIFEST.in Initial refactor. Currently hardcoded to macOS. May 4, 2017
README.md updated readme Nov 5, 2019
appveyor.yml
ez_setup.py About to distribute jpy via platform wheels (issue #59) Sep 8, 2015
get-pip.py About to distribute jpy via platform wheels (issue #59) Sep 8, 2015
jpyutil.py fixed jpyutil logging vs logger issue Nov 12, 2018
pom.xml starting 0.10 Jun 25, 2018
setup.cfg About to release v0.8 Sep 7, 2015
setup.py formatted code Nov 5, 2019
winbuild.cmd update to Python 3.5 May 3, 2017

README.md

Build Status Build Status Documentation Status

jpy - a Python-Java Bridge

jpy is a bi-directional Python-Java bridge which you can use to embed Java code in Python programs or the other way round. It has been designed particularly with regard to maximum data transfer speed between the two languages. It comes with a number of outstanding features:

  • Fully translates Java class hierarchies to Python
  • Transparently handles Java method overloading
  • Support of Java multi-threading
  • Fast and memory-efficient support of primitive Java array parameters via Python buffers (e.g. Numpy arrays)
  • Support of Java methods that modify primitive Java array parameters (mutable parameters)
  • Java arrays translate into Python sequence objects
  • Java API for accessing Python objects (jpy.jar)

jpy has been tested with Python 2.7, 3.3-3.6, Oracle Java 7 and 8 JDKs and OpenJDK 8.

The initial development of jpy has been driven by the need to write Python extensions to an established scientific imaging application programmed in Java, namely the SNAP toolbox, the SeNtinel Application Platform project, funded by the European Space Agency (ESA). Writing such Python plug-ins for a Java application usually requires a bi-directional communication between Python and Java since the Python extension code must be able to call back into the Java APIs.

For more information please have a look into jpy's

How to build wheels for Linux and Mac

Install a JDK 8, preferably the Oracle distribution. Set JDK_HOME or JPY_JDK_HOME to point to your JDK installation and run the build script:

$ export JDK_HOME=<your-jdk-dir>
$ export JAVA_HOME=$JDK_HOME
$ python get-pip.py
$ python setup.py build maven bdist_wheel

On success, the wheel is found in the dist directory.

To deploy the jpy.jar (if you don't know why you need this step, this is not for you): ::

$ mvn clean deploy -DskipTests=true

How to build a wheel for Windows

If you are on Windows, please note that if you run a 32-bit Python you'll also need a 32-bit JDK. Set JDK_HOME or JPY_JDK_HOME to point to your JDK installation. You'll need Windows SDK 7.1 or Visual Studio C++ to build the sources. With Windows SDK 7.1::

> SET VS90COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\
> SET DISTUTILS_USE_SDK=1
> C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\setenv /x64 /release
> SET JDK_HOME=<your-jdk-dir>
> python get-pip.py
> python setup.py build maven bdist_wheel

With Visual Studio 14 and higher it is much easier::

> SET VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
> SET JDK_HOME=<your-jdk-dir>
> python get-pip.py
> python setup.py build maven bdist_wheel

On success, the wheel is found in the dist directory.

How to install from sources

TBD

Releasing jpy

The target reader of this section is a jpy developer wishing to release a new jpy version. Note: You need to have Sphinx installed to update the documentation.

  1. Make sure all Java and Python units tests run green
  2. Remove the -SNAPSHOT qualifier from versions names in both the Maven pom.xml and setup.py files.
  3. Generate Java API doc by running mvn javadoc:javadoc which will update directory doc/_static
  4. Update documentation, cd doc and run make html
  5. http://peterdowns.com/posts/first-time-with-pypi.html
You can’t perform that action at this time.