Skip to main content

Enables Python to dynamically access arbitrary Java objects (ctypes/cffi-based Py4J)

Project description

Currently only as placeholder (because a base package jtypes.jvm is still in development)

jtypes.py4j

Enables Python to dynamically access arbitrary Java objects.

Overview

jtypes.py4j enables Python programs to dynamically access arbitrary Java objects via Java’s Native Invocation Interface (JNI).

PyPI record.

jtypes.py4j is a lightweight Python package, based on the ctypes or cffi library.
It is an almost fully compliant implementation of Barthelemy Dagenais’s Py4J package by reimplementing its functionality in a clean Python via JNI instead of Python and Java via custom API service.

About Py4J:

Borrowed from the original website:

Py4J enables Python programs running in a Python interpreter to dynamically access Java objects in a Java Virtual Machine. Methods are called as if the Java objects resided in the Python interpreter and Java collections can be accessed through standard Python collection methods. Py4J also enables Java programs to call back Python objects.

Here is a brief example of what you can do with Py4J.
The following Python program creates a java.util.Random instance from a JVM and calls some of its methods.
>>> from py4j.java_gateway import JavaGateway
>>> gateway = JavaGateway()                  # connect to the JVM
>>> random = gateway.jvm.java.util.Random()  # create a java.util.Random instance
>>> number1 = random.nextInt(10)             # call the Random.nextInt method
>>> number2 = random.nextInt(10)
>>> print(number1,number2)
(2, 7)

Requirements

  • Java Runtime (JRE) or Java Development Kit (JDK), and NumPy.

Installation

Prerequisites:

To install run:

python -m pip install --upgrade jtypes.py4j

To ensure everything is running correctly you can run the tests using:

python -m jt.py4j.tests

Development

Visit development page

Installation from sources:

Clone the sources and run:

python -m pip install ./jtypes.py4j

or on development mode:

python -m pip install --editable ./jtypes.py4j

Prerequisites:

  • Development is strictly based on tox. To install it run:

    python -m pip install tox

License

Copyright (c) 2015-2018, Adam Karpierz

Licensed under the BSD license
Please refer to the accompanying LICENSE file.

Authors

Changelog

0.10.8a1 (2018-11-08)

  • Synchro with Py4J master branch (v.0.10.8).

  • Update of the required setuptools version.

  • Minor setup and tests improvements.

0.10.7a2 (2018-09-14)

  • Synchro with Py4J master branch (v.0.10.7).

0.10.7a1 (2018-06-15)

  • Synchro with Py4J master branch (v.0.10.7).

0.10.6a4 (2018-05-22)

  • Update of the required setuptools version.

0.10.6a3 (2018-02-26)

  • Improvement and simplification of setup and packaging.

0.10.6a2 (2018-01-29)

  • Development moved to github.

  • Version numbering in sync. with the original Py4J.

0.0.1a1 (2017-01-10)

  • First alpha release.

0.0.1a0 (2015-08-05)

  • Initial version.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jtypes.py4j-0.10.8a1.zip (646.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page