Skip to main content

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

Metadata

Release files for import-java 0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for import-java 0.6
File Size Uploaded Provenance Actions
import-java-0.6.tar.gz 4.3 kB Without provenance Details for import-java-0.6.tar.gz

Release files / import-java-0.6.tar.gz

Download URL import-java-0.6.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
31d742ef021b0036a287a817abbe7e2a4691bfd249fbe14b5d789a1387d24baa
BLAKE2b-256 checksum
How to use checksums
1e9d3af732663c61c0662b97db33b4d82d7d6f23f9f3ebe9f093a60c7ebf984a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for import-java 0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.6 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page