Skip to main content

Import Java packages seamlessly into CPython

Project description

import-java

Build Status Code Coverage PyPI Version Python Compatibility License

Import your Java packages seamlessly into CPython.

Quick Start

We'll create a temporary file in Java and then read it in Python to illustrate the usage:

>>> import java
>>> with java:
...     from java.lang import String
...     from java.nio.file import Files
...
>>> temp_path = Files.createTempFile('sample', '.tmp')
>>> sample_text = String('Greetings from Java')
>>> Files.write(temp_path, sample_text.getBytes())
<java.nio.file.Path at 0x... jclass=java/nio/file/Path jself=...>

>>> with open(temp_path.toString()) as f:
...     print(repr(f.read()))
...
'Greetings from Java'

You can also use _ as a short alias for java.lang:

>>> with java:
...     from _ import System
...
>>> System.getProperties().get('java.specification.version')
'1.8'

Wildcard imports (such as from java.util import *) are not supported yet.

Dependencies

Either PyJNIus or JavaBridge. PyJNIus is preferred, as JavaBridge cannot disambiguate overloaded methods with the same number of parameters.

Installation

$ pip install import-java

License

MIT.

See also

Project details


Release history Release notifications | RSS feed

This version

0.6

Download files

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

Source Distribution

import-java-0.6.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file import-java-0.6.tar.gz.

File metadata

  • Download URL: import-java-0.6.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for import-java-0.6.tar.gz
Algorithm Hash digest
SHA256 31d742ef021b0036a287a817abbe7e2a4691bfd249fbe14b5d789a1387d24baa
MD5 ebc37d99c8e9caf8d21ca553b5ad631c
BLAKE2b-256 1e9d3af732663c61c0662b97db33b4d82d7d6f23f9f3ebe9f093a60c7ebf984a

See more details on using hashes here.

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