Skip to main content

Import Java packages seamlessly into CPython

Project description


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(
'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')

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


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


$ pip install import-java



See also

Project details

Release history Release notifications | RSS feed

This version


Download files

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

Files for import-java, version 0.6
Filename, size File type Python version Upload date Hashes
Filename, size import-java-0.6.tar.gz (4.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page